1
0
mirror of https://gitee.com/coder-xiaomo/flashsale synced 2025-09-12 06:51:38 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

完成基本数据库查询

This commit is contained in:
2022-03-01 15:41:12 +08:00
parent f5fa1aa4b5
commit 25cc33f5bf
2 changed files with 21 additions and 4 deletions

View File

@@ -1,20 +1,36 @@
package com.cxyxiaomo.flashsale; 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.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 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.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
/** /**
* Hello world! * Hello world!
*/ */
@EnableAutoConfiguration // 将这个App的启动类当成一个自动化可支持配置的Bean并且能够开启整个一个工程类的基于SpringBoot的一个自动化配置 // @EnableAutoConfiguration // 将这个App的启动类当成一个自动化可支持配置的Bean并且能够开启整个一个工程类的基于SpringBoot的一个自动化配置
@SpringBootApplication(scanBasePackages = {"com.cxyxiaomo.flashsale"})
@RestController @RestController
@MapperScan("com.cxyxiaomo.flashsale.dao") // 设置DAO存放路径
public class App { public class App {
@Autowired
private userDataObjectMapper userDOMapper;
@RequestMapping("/") @RequestMapping("/")
public String home() { 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) { public static void main(String[] args) {

View File

@@ -1,7 +1,6 @@
server.port=8090 server.port=8090
#mybatis.mapper-locations=classpath:mapping/*.xml
mybatis.mapperLocations=classpath:mapping/*.xml mybatis.mapperLocations=classpath:mapping/*.xml
spring.datasource.name=flashsale spring.datasource.name=flashsale
@@ -10,3 +9,5 @@ spring.datasource.username=root
spring.datasource.password=111111 spring.datasource.password=111111
# 使用druid数据源 # 使用druid数据源
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.driverClassName=com.mysql.jdbc.Driver