首页 > 数据库 >2024.11.12(spring boot创建数据库)

2024.11.12(spring boot创建数据库)

时间:2025-01-10 23:11:55浏览次数:1  
标签:12 springboot spring boot mybatis org id

前端代码
UserMapper.xml

<select id="queryUserById" resultType="User" parameterType="int">
    select * from springboot.user where id = #{id};
</select>

<insert id="addUser">
    insert into springboot.user (name, id, sex) VALUES (#{name},#{id},#{sex})
</insert>

<delete id="deleteUserById">
    delete from springboot.user where id=#{id}
</delete>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 application.properties spring.datasource.username=root spring.datasource.password=admin spring.datasource.url=jdbc:mysql://localhost:3306/mybatis?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

??mybatis

mybatis.type-aliases-package=com.example.springboot.pojo
mybatis.mapper-locations=classpath:mybatis/mapper/*.xml
server.port=8080

pom.xml


4.0.0
com.example
springBoot
0.0.1-SNAPSHOT
springBoot
springBoot

<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-boot.version>2.6.13</spring-boot.version>



org.mybatis.spring.boot
mybatis-spring-boot-starter
2.1.1


org.projectlombok
lombok


org.springframework.boot
spring-boot-starter-jdbc


org.springframework.boot
spring-boot-starter-web

    <dependency>
        <groupId>com.mysql</groupId>
        <artifactId>mysql-connector-j</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>${spring-boot.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>${spring-boot.version}</version>
            <configuration>
                <mainClass>com.example.springboot.Application</mainClass>
                <skip>true</skip>
            </configuration>
            <executions>
                <execution>
                    <id>repackage</id>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

标签:12,springboot,spring,boot,mybatis,org,id
From: https://www.cnblogs.com/yangsongduo/p/18664869

相关文章