Skip to content

Commit 8aef102

Browse files
authored
Merge pull request #1 from mercyblitz/master
合并
2 parents 7c534e1 + 5cfff5b commit 8aef102

File tree

177 files changed

+5823
-8
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

177 files changed

+5823
-8
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Segment Fault 在线讲堂 代码工程
6666

6767

6868

69-
### [第七节 MyBatis](https://segmentfault.com/l/1500000009952220)
69+
### [第七节 MyBatis](https://segmentfault.com/l/1500000009952220)([课件](https://github.com/mercyblitz/segmentfault-lessons/tree/master/spring-boot/lesson-7))
7070

7171
* 主要内容
7272

@@ -77,7 +77,7 @@ Segment Fault 在线讲堂 代码工程
7777

7878

7979

80-
### [第八节 Java Persistence API](https://segmentfault.com/l/1500000009952527)
80+
### [第八节 Java Persistence API](https://segmentfault.com/l/1500000009952527)([课件](https://github.com/mercyblitz/segmentfault-lessons/tree/master/spring-boot/lesson-8))
8181

8282
* 主要内容
8383

@@ -87,7 +87,8 @@ Segment Fault 在线讲堂 代码工程
8787

8888

8989

90-
### [第九节 NoSQL](https://segmentfault.com/l/1500000009957330)
90+
### [第九节 NoSQL](https://segmentfault.com/l/1500000009957330)([课件](https://github.com/mercyblitz/segmentfault-lessons/tree/master/spring-boot/lesson-9)) [[问答](https://segmentfault.com/l/1500000009957330/d/1560000010384965)]
91+
9192

9293
* 主要内容:
9394

@@ -97,7 +98,7 @@ Segment Fault 在线讲堂 代码工程
9798

9899

99100

100-
### [第十节 缓存](https://segmentfault.com/l/1500000009970812)
101+
### [第十节 缓存](https://segmentfault.com/l/1500000009970812)([课件](https://github.com/mercyblitz/segmentfault-lessons/tree/master/spring-boot/lesson-10)) [[问答](https://segmentfault.com/l/1500000009970812/d/1560000010509920)]
101102

102103
* 主要内容
103104

@@ -108,7 +109,7 @@ Segment Fault 在线讲堂 代码工程
108109

109110

110111

111-
### [第十一节 消息](https://segmentfault.com/l/1500000009971600)
112+
### [第十一节 消息](https://segmentfault.com/l/1500000009971600)([课件](https://github.com/mercyblitz/segmentfault-lessons/tree/master/spring-boot/lesson-11)) [[问答](https://segmentfault.com/l/1500000009971600/d/1560000010580012)]
112113

113114
* 主要内容
114115

@@ -120,7 +121,7 @@ Segment Fault 在线讲堂 代码工程
120121

121122

122123

123-
### [第十二节 验证](https://segmentfault.com/l/1500000009971716)
124+
### [第十二节 验证](https://segmentfault.com/l/1500000009971716) ([课件](https://github.com/mercyblitz/segmentfault-lessons/tree/master/spring-boot/lesson-12)) [[问答](https://segmentfault.com/l/1500000009971716/d/1560000010630935)]
124125

125126
* 主要内容
126127

3.76 MB
Binary file not shown.
Binary file not shown.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
target/
2+
!.mvn/wrapper/maven-wrapper.jar
3+
4+
### STS ###
5+
.apt_generated
6+
.classpath
7+
.factorypath
8+
.project
9+
.settings
10+
.springBeans
11+
12+
### IntelliJ IDEA ###
13+
.idea
14+
*.iws
15+
*.iml
16+
*.ipr
17+
18+
### NetBeans ###
19+
nbproject/private/
20+
build/
21+
nbbuild/
22+
dist/
23+
nbdist/
24+
.nb-gradle/
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>com.segmentfault</groupId>
7+
<artifactId>spring-boot-lesson-10</artifactId>
8+
<version>0.0.1-SNAPSHOT</version>
9+
<packaging>jar</packaging>
10+
11+
<name>spring-boot-lesson-10</name>
12+
<description>Demo project for Spring Boot</description>
13+
14+
<parent>
15+
<groupId>org.springframework.boot</groupId>
16+
<artifactId>spring-boot-starter-parent</artifactId>
17+
<version>1.5.6.RELEASE</version>
18+
<relativePath/> <!-- lookup parent from repository -->
19+
</parent>
20+
21+
<properties>
22+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
23+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
24+
<java.version>1.8</java.version>
25+
</properties>
26+
27+
<dependencies>
28+
29+
<dependency>
30+
<groupId>org.springframework.boot</groupId>
31+
<artifactId>spring-boot-starter-actuator</artifactId>
32+
</dependency>
33+
34+
<dependency>
35+
<groupId>javax.cache</groupId>
36+
<artifactId>cache-api</artifactId>
37+
</dependency>
38+
39+
<dependency>
40+
<groupId>org.springframework.boot</groupId>
41+
<artifactId>spring-boot-starter-cache</artifactId>
42+
</dependency>
43+
44+
<dependency>
45+
<groupId>org.springframework.boot</groupId>
46+
<artifactId>spring-boot-starter-data-redis</artifactId>
47+
</dependency>
48+
49+
<!--<dependency>-->
50+
<!--<groupId>org.springframework</groupId>-->
51+
<!--<artifactId>spring-jdbc</artifactId>-->
52+
<!--</dependency>-->
53+
54+
<dependency>
55+
<groupId>org.springframework.boot</groupId>
56+
<artifactId>spring-boot-starter-web</artifactId>
57+
</dependency>
58+
59+
<dependency>
60+
<groupId>org.springframework.boot</groupId>
61+
<artifactId>spring-boot-starter-test</artifactId>
62+
<scope>test</scope>
63+
</dependency>
64+
</dependencies>
65+
66+
<build>
67+
<plugins>
68+
<plugin>
69+
<groupId>org.springframework.boot</groupId>
70+
<artifactId>spring-boot-maven-plugin</artifactId>
71+
</plugin>
72+
</plugins>
73+
</build>
74+
75+
76+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.segmentfault.springbootlesson10;
2+
3+
import org.springframework.cache.CacheManager;
4+
import org.springframework.cache.annotation.EnableCaching;
5+
import org.springframework.cache.concurrent.ConcurrentMapCache;
6+
import org.springframework.cache.support.SimpleCacheManager;
7+
import org.springframework.context.annotation.Bean;
8+
import org.springframework.context.annotation.Configuration;
9+
import org.springframework.transaction.annotation.EnableTransactionManagement;
10+
11+
import java.util.Arrays;
12+
13+
/**
14+
* 缓存的配置
15+
*
16+
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
17+
* @see
18+
* @since 2017.08.04
19+
*/
20+
@Configuration
21+
@EnableCaching
22+
//@EnableTransactionManagement
23+
public class CacheConfiguration {
24+
25+
@Bean
26+
public CacheManager simpleCacheManager() {
27+
28+
SimpleCacheManager simpleCacheManager = new SimpleCacheManager();
29+
30+
ConcurrentMapCache cache = new ConcurrentMapCache("cache-1");
31+
ConcurrentMapCache personsCache = new ConcurrentMapCache("persons");
32+
33+
simpleCacheManager.setCaches(Arrays.asList(cache, personsCache));
34+
35+
return simpleCacheManager;
36+
37+
}
38+
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.segmentfault.springbootlesson10;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
import java.util.concurrent.locks.Lock;
7+
import java.util.concurrent.locks.ReentrantLock;
8+
9+
@SpringBootApplication
10+
public class SpringBootLesson10Application {
11+
12+
//lock-free
13+
// private volatile int data;
14+
//
15+
private synchronized void doSome() {
16+
17+
Lock outterLock = new ReentrantLock();
18+
Lock innterLock = new ReentrantLock();
19+
20+
try {
21+
outterLock.tryLock();
22+
innterLock.tryLock();
23+
} finally {
24+
innterLock.unlock();
25+
outterLock.unlock();
26+
}
27+
28+
}
29+
30+
31+
public static void main(String[] args) {
32+
SpringApplication.run(SpringBootLesson10Application.class, args);
33+
34+
// Integer var = new Integer(1);
35+
// Integer var2 = new Integer(1);
36+
// System.out.println(var.hashCode());
37+
// System.out.println(var2.hashCode());
38+
//
39+
// System.out.println(System.identityHashCode(var));
40+
// System.out.println(System.identityHashCode(var2));
41+
42+
}
43+
}

0 commit comments

Comments
 (0)