update 8.20

This commit is contained in:
2025-08-20 19:31:43 +08:00
parent 8a34d3c7ca
commit cfcda48e34
5 changed files with 29 additions and 56 deletions

View File

@ -72,6 +72,13 @@
<scope>test</scope>
</dependency>
<!-- knife4j -->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
<version>4.4.0</version>
</dependency>
</dependencies>

View File

@ -1,30 +0,0 @@
package com.example.practice.controller;
import com.example.practice.entity.User;
import com.example.practice.mapper.UserMapper;
import com.example.practice.mapper.UserMapperImpl;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
//@Controller // UserController userController = new UserController(); userController对象放到SpringIOC容器中
//@ResponseBody // 把返回值打印到浏览器上
@RestController // @Controller + @ResponseBody
@RequestMapping("/user")
public class UserController {
private UserMapper userMapper = new UserMapperImpl();
@GetMapping("/selectAll")
public List<User> queryAll() {
List<User> users = userMapper.selectAll();
return users;
}
}

View File

@ -1,9 +1,11 @@
package com.example.practice.mapper;
import com.example.practice.entity.User;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper // 将UserMapper的接口实现类对象生成放入SpringIOC容器 UserMapperImpl userMapperImpl = new UserMapperImpl()
public interface UserMapper {
List<User> selectAll();

View File

@ -1,6 +0,0 @@
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/practice
username: root
password: 123456

View File

@ -1,28 +1,28 @@
<!--<?xml version="1.0" encoding="UTF-8" ?>-->
<!--<!DOCTYPE configuration-->
<!-- PUBLIC "-//mybatis.org//DTD Config 3.0//EN"-->
<!-- "http://mybatis.org/dtd/mybatis-3-config.dtd">-->
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<!--<configuration>-->
<configuration>
<!-- <environments default="dev">-->
<environments default="dev">
<!-- <environment id="dev">-->
<!-- <transactionManager type="JDBC"/>-->
<!-- <dataSource type="POOLED">-->
<!-- <property name="driver" value="com.mysql.cj.jdbc.Driver"/>-->
<!-- <property name="url" value="jdbc:mysql://localhost:3306/practice"/>-->
<!-- <property name="username" value="root"/>-->
<!-- <property name="password" value="123456"/>-->
<!-- </dataSource>-->
<!-- </environment>-->
<environment id="dev">
<transactionManager type="JDBC"/>
<dataSource type="POOLED">
<property name="driver" value="com.mysql.cj.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/practice"/>
<property name="username" value="root"/>
<property name="password" value="123456"/>
</dataSource>
</environment>
<!-- </environments>-->
</environments>
<!-- <mappers>-->
<!-- <mapper resource="mapper/UserMapper.xml"/>-->
<!-- </mappers>-->
<mappers>
<mapper resource="mapper/UserMapper.xml"/>
</mappers>
<!--</configuration>-->
</configuration>