SpringBoot运行显示Application run failed
错误:Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.2021-06-28 14:27:13.827 ERROR 7512 --- [restartedMain] o.s.boot.SpringApplication: A
错误:
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-06-28 14:27:13.827 ERROR 7512 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
背景
已经到复习阶段了,老师让写一个SpringBoot项目,但是我死活运行不出来。运行Application显示无法运行application。
中间遇到一些错误,在百度上搜了一下,是这样的:
在Application中的注解中有@SpringBootApplication
,应该用@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
代替,结果依旧运行不出来。
exclude,排除此类的AutoConfig,即禁止 SpringBoot 自动注入数据源配置。在这里是排除了mybits的自动注入,结果mapper层出现了问题。
今天让老师看了一下,是yml文件出了问题。
忘了写
spring
关键字,这些我也不懂。
server:
port: 5050 # tomcat端口号
servlet:
context-path: /UserModel
spring:# 这里忘记写了,使得datesource属于server下
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/1202?useSSL=false&serverTimezone=Asia/Shanghai&characterEncoding=utf-8
username: root
password: root
访问Controller时出现了一个错误
报的错误与此相同: https://www.cnblogs.com/yangguanglei/p/11720776.html
would dispatch back to the current handler URL [/UserModel/queryUserById]
其实时是搞不清楚@Controller
、@RestController
的区别
@Controller
、@RestController
?
忘了get和post的区别
[https://blog.csdn.net/qq_38889350/article/details/112187977?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522162488620516780357263064%2522%252C%2522scm%2522%253A%252220140713.130102334…%2522%257D&request_id=162488620516780357263064&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2alltop_positive~default-1-112187977.first_rank_v2_pc_rank_v29_2&utm_term=get%E5%92%8Cpost%E7%9A%84%E5%8C%BA%E5%88%AB&spm=1018.2226.3001.4187]
总之get是可以直接在地址栏访问的,post不行
get请求访问数组
写法:
http://localhost:5050/UserModel/deleteUserByIds?ids=3,4
更多推荐
所有评论(0)