File tree 5 files changed +21
-13
lines changed
java/net/codingme/boot/domain
test/java/net/codingme/boot
5 files changed +21
-13
lines changed Original file line number Diff line number Diff line change 43
43
<artifactId >spring-boot-starter-thymeleaf</artifactId >
44
44
</dependency >
45
45
46
+ <!-- apo 切面支持 -->
46
47
<dependency >
47
48
<groupId >org.springframework.boot</groupId >
48
49
<artifactId >spring-boot-starter-aop</artifactId >
55
56
<version >1.2.47</version >
56
57
</dependency >
57
58
58
-
59
59
<!-- Lombok 工具 -->
60
60
<dependency >
61
61
<groupId >org.projectlombok</groupId >
97
97
<artifactId >mysql-connector-java</artifactId >
98
98
</dependency >
99
99
100
- <!-- 引入druid数据源这里应该使用和springboot整合的jar。不然sql监控无效 -->
101
- <!-- <dependency>-->
102
- <!-- <groupId>com.alibaba</groupId>-->
103
- <!-- <artifactId>druid</artifactId>-->
104
- <!-- <version>1.1.12</version>-->
105
- <!-- </dependency>-->
100
+ <!-- 阿里 druid 数据源 -->
106
101
<dependency >
107
102
<groupId >com.alibaba</groupId >
108
103
<artifactId >druid-spring-boot-starter</artifactId >
109
104
<version >1.1.10</version >
110
105
</dependency >
111
-
112
-
113
106
</dependencies >
114
107
115
108
<build >
Original file line number Diff line number Diff line change 1
1
package net .codingme .boot .domain ;
2
2
3
+
3
4
import lombok .AllArgsConstructor ;
4
- import lombok .Builder ;
5
5
import lombok .Data ;
6
6
import lombok .NoArgsConstructor ;
7
7
import org .springframework .format .annotation .DateTimeFormat ;
8
8
9
9
import javax .persistence .*;
10
10
import javax .validation .constraints .NotNull ;
11
11
import java .util .Date ;
12
- import java .util .List ;
13
12
14
13
/**
15
14
* <p>
@@ -64,5 +63,4 @@ public class User {
64
63
* 技能
65
64
*/
66
65
private String skills ;
67
-
68
66
}
Original file line number Diff line number Diff line change 13
13
@ Repository
14
14
public interface UserRepository extends JpaRepository <User , Integer > {
15
15
16
+ /**
17
+ * 一个自定义方法,根据 username 和 password 查询 User 信息
18
+ */
16
19
User findByUsernameAndPassword (String username , String password );
17
20
18
21
}
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ spring.jpa.database-platform=org.hibernate.dialect.MySQL55Dialect
43
43
# person.dog.name=旺财
44
44
# person.dog.age=1
45
45
46
- # ###########################################################
46
+ # ###########################################################x
47
47
# 生成随机值
48
48
bootapp.secret =$ {random.value}
49
49
bootapp.number =$ {random.int}
Original file line number Diff line number Diff line change 1
1
package net .codingme .boot ;
2
2
3
+ import com .alibaba .fastjson .JSON ;
4
+ import net .codingme .boot .domain .User ;
5
+ import net .codingme .boot .domain .repository .UserRepository ;
3
6
import org .junit .Test ;
4
7
import org .junit .runner .RunWith ;
5
8
import org .springframework .beans .factory .annotation .Autowired ;
8
11
9
12
import javax .sql .DataSource ;
10
13
import java .sql .SQLException ;
14
+ import java .util .List ;
11
15
12
16
@ RunWith (SpringRunner .class )
13
17
@ SpringBootTest
@@ -16,6 +20,16 @@ public class SpringbootDataJpaApplicationTests {
16
20
@ Autowired
17
21
private DataSource dataSource ;
18
22
23
+ @ Autowired
24
+ private UserRepository userRepository ;
25
+
26
+ @ Test
27
+ public void testUser (){
28
+ List <User > one = userRepository .findAll ();
29
+ System .out .println (JSON .toJSONString (one ));
30
+ }
31
+
32
+
19
33
@ Test
20
34
public void contextLoads () throws SQLException {
21
35
System .out .println (dataSource .getClass ());
You can’t perform that action at this time.
0 commit comments