mirror of
https://gitee.com/coder-xiaomo/flashsale
synced 2025-01-10 19:58:14 +08:00
完成基本数据库查询
This commit is contained in:
parent
f5fa1aa4b5
commit
25cc33f5bf
@ -1,20 +1,36 @@
|
||||
package com.cxyxiaomo.flashsale;
|
||||
|
||||
import com.cxyxiaomo.flashsale.dao.userDataObjectMapper;
|
||||
import com.cxyxiaomo.flashsale.dataobject.userDataObject;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* Hello world!
|
||||
*/
|
||||
@EnableAutoConfiguration // 将这个App的启动类当成一个自动化,可支持配置的Bean,并且能够开启整个一个工程类的基于SpringBoot的一个自动化配置
|
||||
// @EnableAutoConfiguration // 将这个App的启动类当成一个自动化,可支持配置的Bean,并且能够开启整个一个工程类的基于SpringBoot的一个自动化配置
|
||||
@SpringBootApplication(scanBasePackages = {"com.cxyxiaomo.flashsale"})
|
||||
@RestController
|
||||
@MapperScan("com.cxyxiaomo.flashsale.dao") // 设置DAO存放路径
|
||||
public class App {
|
||||
|
||||
@Autowired
|
||||
private userDataObjectMapper userDOMapper;
|
||||
|
||||
|
||||
@RequestMapping("/")
|
||||
public String home() {
|
||||
return "Hello world!";
|
||||
userDataObject userDO = userDOMapper.selectByPrimaryKey(1);
|
||||
if (userDO == null) {
|
||||
return "用户对象不存在!";
|
||||
} else {
|
||||
return userDO.getName();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
server.port=8090
|
||||
|
||||
#mybatis.mapper-locations=classpath:mapping/*.xml
|
||||
mybatis.mapperLocations=classpath:mapping/*.xml
|
||||
|
||||
spring.datasource.name=flashsale
|
||||
@ -9,4 +8,6 @@ spring.datasource.url=jdbc:mysql://127.0.0.1:3306/flashsale
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=111111
|
||||
|
||||
# 使用druid数据源
|
||||
# 使用druid数据源
|
||||
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
|
||||
spring.datasource.driverClassName=com.mysql.jdbc.Driver
|
Loading…
Reference in New Issue
Block a user