---
title: "springboot项目错误"
author: "Janne"
date: "2020-07-19T09:30:18Z"
tags: ["数据库连接", "错误"]
categories: ["编程语言"]
slug: "springboot"
draft: false
lastmod: "2020-11-05T22:54:05Z"
id: 2515753
url: "https://janne.iteye.com/blog/2515753"
---

swagger页面修改显示 war：参考https://www.jb51.cc/java/125142.html 问题一：idea创建spring boot项目时无法访问https://start.spring.io的解决方法 处理方法：建议使用阿里云的网址：https://start.aliyun.com/ idea编辑器安装及重点设置请参考：https://blog.csdn.net/zyplanke/article/details/105576304 问题二：java.lang.IllegalArgumentException: jdbcUrl is required with driverClassName. 问题原因：1.5.x版本和2.0.x版本是有很大区别 解决办法， 方法一：修改配置application.properties 1.5.x版本的application.properties是这样命名的 spring.datasource.url 而2.0.x版以后是这样写的： spring.datasource.jdbc-url 方法二：在datasource后面添加hikari spring.datasource.hikari.driverClassName 方法三：在数据源配置时使用DataSourceProperties方法 参考：https://blog.csdn.net/MrLi\_IT/article/details/80909078 问题三：Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required 原因：mybatis-spring-1.2.0中取消了自动注入SqlSessionFactory 和 SqlSessionTemplate 解决方案：因为我们dao层是继承于一个dao基类，所以只要在这个基类中注入任意一个属性即可。SqlSessionFactory在spring配置文件中已经配置。 public class CommonDao extends SqlSessionDaoSupport { @Resource public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory){ super.setSqlSessionFactory(sqlSessionFactory); } 参考：https://www.cnblogs.com/hawk0035/p/3337283.html?utm\_source=tuicool 问题四：org.springframework.boot.devtools.restart.SilentExitExceptionHandler$SilentExitException 现状：在main()方法上，SpringApplication.run()一但放到try...catch块里就会导致devtools抛个异常报上面的错误，但实际上又不影响任何功能，devtools的热部署功能也仍然生效 解决方法：把main()里的try...catch去掉，或者把app.run(args)这句移出try...catch，或者catch到异常不要printStackTrace()，再运行就不会有错误日志了。 问题五： IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start componentatalina.LifecycleException: Failed to start component 错误原因：jar冲突或者版本不匹配 场景：引入cxf-spring-boot-starter-jaxws 3.2.4依赖后报错，后更改为其他低版本，依然再报错，后在网上看了把它换为不是springboot的即可，尝试 成功！ 替换为： org.apache.cxf cxf-rt-transports-http 3.1.11 org.apache.cxf cxf-rt-frontend-jaxws 3.1.11 参考：https://blog.csdn.net/hawako/article/details/80556676?utm\_medium=distribute.pc\_relevant.none-task-blog-blogcommendfrommachinelearnpai2-1.channel\_param&depth\_1-utm\_source=distribute.pc\_relevant.none-task-blog-blogcommendfrommachinelearnpai2-1.channel\_param 问题6：连接数据库遇到java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support. at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:545) 解决办法： 修改位：jdbcUrl=jdbc:mysql://localhost:3306/secondskill?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai