POM.XML
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.9</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.yinming</groupId>
<artifactId>sprintboot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>sprintboot</name>
<description>sprintboot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>nexus-aliyun</id>
<name>nexus-aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>public</id>
<name>aliyun nexus</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>
springApplication
package com.yinming.sprintboot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@SpringBootApplication
public class SprintbootApplication {
public static void main(String[] args) {
SpringApplication.run(SprintbootApplication.class, args);
}
@GetMapping("/")
public String index()
{
return "ok";
}
}
Application.properties
server.port=9090 spring.datasource.url = jdbc:mysql://localhost:3306/yinming?serverTimezone=GMT%2b8 spring.datasource.username = root spring.datasource.password = 123456 spring.datasource.driver-class-name= com.mysql.cj.jdbc.Driver spring.datasource.max-idle=8 spring.datasource.min-idle=8 spring.datasource.initial-size=10
Application.yml
port: 9090
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/yinming?serverTimezone=GMT%2b8
username: root
password: 123456
max-idle: 8
min-idle: 8
initial-size: 10
Spring Boot与MyBatis整合配置及简单应用
这是一个关于Spring Boot应用的配置和简单示例。项目使用了Spring Boot 2.5.9版本,引入了Spring Boot Starter Web和MyBatis-Spring Boot Starter 2.2.2来实现Web服务和数据库操作。数据库连接采用MySQL,配置了数据源的相关参数。此外,还使用了Lombok进行代码简化。在主类中定义了一个简单的RESTful API,返回'ok'。
6804

被折叠的 条评论
为什么被折叠?



