Skip to content

Commit 6e6d885

Browse files
committed
init
1 parent 3eaba8e commit 6e6d885

File tree

12 files changed

+486
-62
lines changed

12 files changed

+486
-62
lines changed
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<groupId>org.springframework.boot</groupId>
7+
<artifactId>spring-boot-starter-parent</artifactId>
8+
<version>3.5.4</version>
9+
<relativePath/> <!-- lookup parent from repository -->
10+
</parent>
11+
<groupId>com.springboot354</groupId>
12+
<artifactId>springboot354</artifactId>
13+
<version>0.0.1-SNAPSHOT</version>
14+
<name>springboot354</name>
15+
<description>Demo project for Spring Boot</description>
16+
<url/>
17+
<licenses>
18+
<license/>
19+
</licenses>
20+
<developers>
21+
<developer/>
22+
</developers>
23+
<scm>
24+
<connection/>
25+
<developerConnection/>
26+
<tag/>
27+
<url/>
28+
</scm>
29+
<properties>
30+
<java.version>17</java.version>
31+
</properties>
32+
<dependencies>
33+
<dependency>
34+
<groupId>org.springframework.boot</groupId>
35+
<artifactId>spring-boot-starter-web</artifactId>
36+
</dependency>
37+
38+
<dependency>
39+
<groupId>org.springframework.boot</groupId>
40+
<artifactId>spring-boot-devtools</artifactId>
41+
<scope>runtime</scope>
42+
<optional>true</optional>
43+
</dependency>
44+
45+
<!-- Spring Boot Starter Data JPA -->
46+
<dependency>
47+
<groupId>org.springframework.boot</groupId>
48+
<artifactId>spring-boot-starter-data-jpa</artifactId>
49+
</dependency>
50+
51+
<!-- PostgreSQL JDBC 驱动 -->
52+
<dependency>
53+
<groupId>org.postgresql</groupId>
54+
<artifactId>postgresql</artifactId>
55+
<scope>runtime</scope>
56+
</dependency>
57+
58+
<!-- MyBatis-Plus Starter -->
59+
<dependency>
60+
<groupId>com.baomidou</groupId>
61+
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
62+
<version>3.5.9</version>
63+
</dependency>
64+
65+
<!-- 分页使用,非必须 -->
66+
<!--<dependency>-->
67+
<!-- <groupId>com.baomidou</groupId>-->
68+
<!-- <artifactId>mybatis-plus-extension</artifactId>-->
69+
<!-- <version>3.5.4</version>-->
70+
<!--</dependency>-->
71+
72+
<dependency>
73+
<groupId>com.alibaba.fastjson2</groupId>
74+
<artifactId>fastjson2</artifactId>
75+
<version>2.0.55</version>
76+
</dependency>
77+
78+
<dependency>
79+
<groupId>org.projectlombok</groupId>
80+
<artifactId>lombok</artifactId>
81+
<optional>true</optional>
82+
</dependency>
83+
<dependency>
84+
<groupId>org.springframework.boot</groupId>
85+
<artifactId>spring-boot-starter-test</artifactId>
86+
<scope>test</scope>
87+
</dependency>
88+
89+
</dependencies>
90+
91+
<build>
92+
<plugins>
93+
<plugin>
94+
<groupId>org.apache.maven.plugins</groupId>
95+
<artifactId>maven-compiler-plugin</artifactId>
96+
<configuration>
97+
<annotationProcessorPaths>
98+
<path>
99+
<groupId>org.projectlombok</groupId>
100+
<artifactId>lombok</artifactId>
101+
</path>
102+
</annotationProcessorPaths>
103+
</configuration>
104+
</plugin>
105+
<plugin>
106+
<groupId>org.springframework.boot</groupId>
107+
<artifactId>spring-boot-maven-plugin</artifactId>
108+
<configuration>
109+
<excludes>
110+
<exclude>
111+
<groupId>org.projectlombok</groupId>
112+
<artifactId>lombok</artifactId>
113+
</exclude>
114+
</excludes>
115+
</configuration>
116+
</plugin>
117+
</plugins>
118+
</build>
119+
120+
</project>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.springboot354.demo;
2+
3+
import org.mybatis.spring.annotation.MapperScan;
4+
import org.springframework.boot.SpringApplication;
5+
import org.springframework.boot.autoconfigure.SpringBootApplication;
6+
7+
@SpringBootApplication
8+
@MapperScan("com.springboot354.demo.mapper")
9+
public class Springboot354Application {
10+
11+
public static void main(String[] args) {
12+
SpringApplication.run(Springboot354Application.class, args);
13+
}
14+
15+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
11
package com.springboot354.demo.config;
22

3+
4+
import com.baomidou.mybatisplus.annotation.DbType;
5+
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
6+
//import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
7+
import org.mybatis.spring.annotation.MapperScan;
8+
import org.springframework.context.annotation.Bean;
9+
import org.springframework.context.annotation.Configuration;
10+
11+
@Configuration
12+
@MapperScan("com.springboot354.demo.mapper")
313
public class MyBatisPlusConfig {
14+
15+
@Bean
16+
public MybatisPlusInterceptor mybatisPlusInterceptor() {
17+
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
18+
19+
//interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.POSTGRE_SQL));
20+
21+
return interceptor;
22+
}
23+
24+
425
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
11
package com.springboot354.demo.config;
22

3+
import jakarta.persistence.EntityManagerFactory;
4+
import org.springframework.context.annotation.Bean;
5+
import org.springframework.context.annotation.Configuration;
6+
import org.springframework.context.annotation.Primary;
7+
import org.springframework.orm.jpa.JpaTransactionManager;
8+
import org.springframework.transaction.PlatformTransactionManager;
9+
import org.springframework.transaction.annotation.EnableTransactionManagement;
10+
11+
import javax.sql.DataSource;
12+
13+
@Configuration
14+
@EnableTransactionManagement
315
public class TransactionConfig {
16+
17+
@Bean
18+
@Primary
19+
public PlatformTransactionManager transactionManager(EntityManagerFactory entityManagerFactory, DataSource dataSource) {
20+
21+
JpaTransactionManager transactionManager = new JpaTransactionManager(entityManagerFactory);
22+
23+
transactionManager.setDataSource(dataSource);
24+
25+
return transactionManager;
26+
}
27+
428
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package com.springboot354.demo.entity;
2+
3+
4+
import com.baomidou.mybatisplus.annotation.IdType;
5+
import com.baomidou.mybatisplus.annotation.TableField;
6+
import com.baomidou.mybatisplus.annotation.TableId;
7+
import com.baomidou.mybatisplus.annotation.TableName;
8+
import jakarta.persistence.*;
9+
import lombok.Data;
10+
11+
import java.util.Date;
12+
13+
//@Data
14+
@Entity
15+
@Table(name = "t_user")
16+
@TableName(value = "t_user")
17+
public class User {
18+
19+
@Id
20+
@GeneratedValue(strategy = GenerationType.IDENTITY)
21+
@TableId(type = IdType.AUTO)
22+
private Long id;
23+
24+
@Column(nullable = false, unique = true)
25+
private String username;
26+
27+
@Column(nullable = false)
28+
private String password;
29+
30+
@Column(nullable = false, name = "created_at")
31+
@TableField(value = "created_at")
32+
private Date createdTime;
33+
34+
35+
36+
// getter setter
37+
public Long getId() {
38+
return id;
39+
}
40+
41+
public void setId(Long id) {
42+
this.id = id;
43+
}
44+
45+
public String getUsername() {
46+
return username;
47+
}
48+
49+
public void setUsername(String username) {
50+
this.username = username;
51+
}
52+
53+
public String getPassword() {
54+
return password;
55+
}
56+
57+
public void setPassword(String password) {
58+
this.password = password;
59+
}
60+
61+
public Date getCreatedTime() {
62+
return createdTime;
63+
}
64+
65+
public void setCreatedTime(Date createdTime) {
66+
this.createdTime = createdTime;
67+
}
68+
}
Lines changed: 60 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,60 @@
1-
package com.springboot354.demo.entity;
2-
3-
4-
import jakarta.persistence.*;
5-
import lombok.Data;
6-
7-
import java.util.Date;
8-
9-
//@Data
10-
@Entity
11-
@Table(name = "t_user")
12-
public class User {
13-
14-
@Id
15-
@GeneratedValue(strategy = GenerationType.IDENTITY)
16-
private Long id;
17-
18-
@Column(nullable = false, unique = true)
19-
private String username;
20-
21-
@Column(nullable = false)
22-
private String password;
23-
24-
@Column(nullable = false, name = "created_at")
25-
private Date createdTime;
26-
27-
28-
29-
// getter setter
30-
public Long getId() {
31-
return id;
32-
}
33-
34-
public void setId(Long id) {
35-
this.id = id;
36-
}
37-
38-
public String getUsername() {
39-
return username;
40-
}
41-
42-
public void setUsername(String username) {
43-
this.username = username;
44-
}
45-
46-
public String getPassword() {
47-
return password;
48-
}
49-
50-
public void setPassword(String password) {
51-
this.password = password;
52-
}
53-
54-
public Date getCreatedTime() {
55-
return createdTime;
56-
}
57-
58-
public void setCreatedTime(Date createdTime) {
59-
this.createdTime = createdTime;
60-
}
61-
}
1+
//package com.springboot354.demo.entity;
2+
//
3+
//
4+
//import jakarta.persistence.*;
5+
//
6+
//import java.util.Date;
7+
//
8+
////@Data
9+
//@Entity
10+
//@Table(name = "t_user")
11+
//public class User2 {
12+
//
13+
// @Id
14+
// @GeneratedValue(strategy = GenerationType.IDENTITY)
15+
// private Long id;
16+
//
17+
// @Column(nullable = false, unique = true)
18+
// private String username;
19+
//
20+
// @Column(nullable = false)
21+
// private String password;
22+
//
23+
// @Column(nullable = false, name = "created_at")
24+
// private Date createdTime;
25+
//
26+
//
27+
//
28+
// // getter setter
29+
// public Long getId() {
30+
// return id;
31+
// }
32+
//
33+
// public void setId(Long id) {
34+
// this.id = id;
35+
// }
36+
//
37+
// public String getUsername() {
38+
// return username;
39+
// }
40+
//
41+
// public void setUsername(String username) {
42+
// this.username = username;
43+
// }
44+
//
45+
// public String getPassword() {
46+
// return password;
47+
// }
48+
//
49+
// public void setPassword(String password) {
50+
// this.password = password;
51+
// }
52+
//
53+
// public Date getCreatedTime() {
54+
// return createdTime;
55+
// }
56+
//
57+
// public void setCreatedTime(Date createdTime) {
58+
// this.createdTime = createdTime;
59+
// }
60+
//}

0 commit comments

Comments
 (0)