初始化自动创建数据库
parent
5f11702cd6
commit
66923f5415
@ -0,0 +1,11 @@
|
||||
package space.caoshd.app
|
||||
|
||||
import org.springframework.boot.SpringApplication
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication
|
||||
|
||||
@SpringBootApplication
|
||||
class Application
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
SpringApplication.run(Application::class.java, *args)
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package space.caoshd.app.config
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan
|
||||
import org.springframework.context.annotation.Configuration
|
||||
|
||||
@Configuration
|
||||
@MapperScan("space.caoshd.app")
|
||||
class MybatisConfig {
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
package space.caoshd.app1.controller
|
||||
package space.caoshd.app.controller
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
import space.caoshd.app1.entity.User
|
||||
import space.caoshd.app1.mapper.UserMapper
|
||||
import space.caoshd.app.entity.User
|
||||
import space.caoshd.app.mapper.UserMapper
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/user")
|
@ -1,4 +1,4 @@
|
||||
package space.caoshd.app1.entity;
|
||||
package space.caoshd.app.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@ -0,0 +1,7 @@
|
||||
package space.caoshd.app.mapper
|
||||
|
||||
import space.caoshd.app.entity.User
|
||||
|
||||
interface UserMapper {
|
||||
fun listUser(user: User): List<User>
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package space.caoshd.app1
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication
|
||||
import space.caoshd.BootstrapApplication
|
||||
|
||||
@SpringBootApplication
|
||||
@MapperScan("space.caoshd")
|
||||
class Application : BootstrapApplication()
|
@ -1,7 +0,0 @@
|
||||
package space.caoshd.app1.mapper
|
||||
|
||||
import space.caoshd.app1.entity.User
|
||||
|
||||
interface UserMapper {
|
||||
fun listUser(user: User): List<User>
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="space.caoshd.app1.mapper.UserMapper">
|
||||
<mapper namespace="space.caoshd.app.mapper.UserMapper">
|
||||
|
||||
<select id="listUser" resultType="space.caoshd.app1.entity.User">
|
||||
<select id="listUser" resultType="space.caoshd.app.entity.User">
|
||||
SELECT * FROM T_USER;
|
||||
</select>
|
||||
|
@ -0,0 +1,3 @@
|
||||
INSERT INTO T_USER (USERNAME, AGE) VALUES ('张三', '18');
|
||||
INSERT INTO T_USER (USERNAME, AGE) VALUES ('李四', '20');
|
||||
INSERT INTO T_USER (USERNAME, AGE) VALUES ('王五', '22');
|
@ -0,0 +1,6 @@
|
||||
DROP TABLE IF EXISTS T_USER ;
|
||||
CREATE TABLE T_USER (
|
||||
ID BIGINT AUTO_INCREMENT PRIMARY KEY,
|
||||
USERNAME VARCHAR(255) NOT NULL,
|
||||
AGE INT
|
||||
);
|
@ -1,9 +0,0 @@
|
||||
DROP TABLE IF EXISTS T_USER ;
|
||||
CREATE TABLE T_USER (
|
||||
ID BIGINT AUTO_INCREMENT PRIMARY KEY,
|
||||
USERNAME VARCHAR(255) NOT NULL,
|
||||
AGE INT
|
||||
);
|
||||
INSERT INTO T_USER (USERNAME, AGE) VALUES ('张三', '18');
|
||||
INSERT INTO T_USER (USERNAME, AGE) VALUES ('李四', '20');
|
||||
INSERT INTO T_USER (USERNAME, AGE) VALUES ('王五', '22');
|
@ -1,4 +1,4 @@
|
||||
package space.caoshd.app1
|
||||
package space.caoshd.app
|
||||
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.springframework.boot.test.context.SpringBootTest
|
Loading…
Reference in New Issue