|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
没有配置啥
- package com.zwl.controller;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.jdbc.core.JdbcTemplate;
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.RestController;
- import java.util.List;
- import java.util.Map;
- @RestController
- public class JDBCController {
- @Autowired
- JdbcTemplate jdbcTemplate;
- @GetMapping("/userList")
- public List<Map<String,Object>> userList(){
- String sql = "select * from user";
- List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);
- return maps;
- }
- }
复制代码- spring:
- datasource:
- username: root
- password: 18870025610
- url: jdbc:mysql://localhost:3306/mybaits?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8
- hikari:
- driver-class-name: com.mysql.jdbc.Driver
复制代码
尝试更改端口号来排除端口冲突的问题,如果更改后可以启动,那可能是端口冲突所导致的。
如果问题仍然存在,就需要更详细的日志信息啦~
你可以增加日志级别来获取更多启动细节:
- logging.level.org.springframework.web=DEBUG
复制代码
添加这行配置后,重新启动应用并检查启动过程中的日志输出。
|
|