parent
4b0d631913
commit
4e8fb9d5a1
@ -1,11 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||
<data-source source="LOCAL" name="mysql@192.168.0.2" uuid="ecc94c92-1fe7-4051-b991-974101f0fd33">
|
||||
<data-source source="LOCAL" name="SpringBoot@localhost" uuid="ecc94c92-1fe7-4051-b991-974101f0fd33">
|
||||
<driver-ref>mysql.8</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
|
||||
<jdbc-url>jdbc:mysql://192.168.0.2:3306/mysql</jdbc-url>
|
||||
<jdbc-url>jdbc:mysql://localhost:3306/SpringBoot?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai</jdbc-url>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
</component>
|
||||
|
||||
@ -0,0 +1,23 @@
|
||||
package com.msb.springboot03.controller;
|
||||
|
||||
import com.msb.springboot03.pojo.User;
|
||||
import com.msb.springboot03.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/user")
|
||||
public class UserController {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@RequestMapping("findAllUser")
|
||||
@ResponseBody
|
||||
public List<User> findAllUser(){
|
||||
return userService.findAllUser();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.msb.springboot03.mapper;
|
||||
|
||||
import com.msb.springboot03.pojo.User;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface UserMapper {
|
||||
List<User> selectAll();
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package com.msb.springboot03.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class User implements Serializable {
|
||||
private Integer userId;
|
||||
private String userName;
|
||||
private String password;
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
package com.msb.springboot03.service;
|
||||
|
||||
import com.msb.springboot03.pojo.User;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface UserService {
|
||||
List<User> findAllUser();
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package com.msb.springboot03.service.impl;
|
||||
|
||||
import com.msb.springboot03.mapper.UserMapper;
|
||||
import com.msb.springboot03.pojo.User;
|
||||
import com.msb.springboot03.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class UserServiceImpl implements UserService {
|
||||
|
||||
@Autowired
|
||||
private UserMapper userMapper;
|
||||
|
||||
@Override
|
||||
public List<User> findAllUser() {
|
||||
return userMapper.selectAll();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
<?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="com.msb.springboot03.mapper.UserMapper">
|
||||
<select id="selectAll" resultType="User">
|
||||
SELECT * FROM USER
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in new issue