赞
踩
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <version>8.0.16</version>
- </dependency>
-
- <dependency>
- <groupId>org.mybatis.spring.boot</groupId>
- <artifactId>mybatis-spring-boot-starter</artifactId>
- <version>2.1.3</version>
- </dependency>
- import org.apache.ibatis.annotations.Mapper;
- import org.apache.ibatis.annotations.Select;
-
- @Mapper
- public interface UserMapper {
- @Select("SELECT `name` FROM user WHERE id = #{id}")
- public String selectManmeById(long id);
- }
- spring:
- datasource:
- url: jdbc:mysql://127.0.0.1:3306/restaurant?serverTimezone=Asia/Shanghai
- username: root
- password: 123456
- driver-class-name: com.mysql.cj.jdbc.Driver
- mybatis:
- configuration:
- map-underscore-to-camel-case: true
- log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
- import com.school.mapper.UserMapper;
- 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;
-
- @Controller
- @ResponseBody
- public class UserController {
- @Autowired
- private UserMapper userMapper;
-
- @RequestMapping("getName")
- public String getName(Long id){
- return userMapper.selectManmeById(id);
- }
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。