1.問題描述:
Failed to bind properties under 'spring.datasource.druid.driver' to java.sql.Driver:
Property: spring.datasource.druid.driver
Value: com.mysql.jdbc.Driver
Origin: class path resource [application.yml]:5:20
Reason: No converter found capable of converting from type [java.lang.String] to type [java.sql.Driver]
解決方法
修改application.yml文件將老版本的
spring:
datasource:
driver: com.mysql.jdbc.Driver
修改爲
spring:
datasource:
druid:
driver-class-name: com.mysql.jdbc.Driver
2.RabbitMq報錯
The bean 'messageConverter', defined in class path resource [com/wanshifu/customer/boot/starter/rabbit/RabbitAutoConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [cn/xy/wanc/sysm/core/config/RabbitConfig.class] and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
解決方法
添加
spring.main.allow-bean-definition-overriding=true
3.過時的property配置
Deprecated configuration property 'spring.http.multipart.maxFileSize'
Deprecated configuration property 'spring.http.multipart.max-request-size'
spring.servlet.multipart.maxFileSize=10Mb
spring.servlet.multipart.maxRequestSize=1000Mb
解決方法
修改爲
spring.servlet.multipart.maxFileSize=10
spring.servlet.multipart.maxRequestSize=1000
server.context-path=/web
修改爲
server.servlet.context-path=/web
4.WebMvcConfigurerAdapter過時
WebMvcConfigurerAdapter過時導致之前的代碼HandlerInterceptor攔截了static靜態資源
解決方法:將之前extends WebMvcConfigurerAdapter修改爲implements WebMvcConfigurer
@Configuration
public class MyWebAppConfigurer implements WebMvcConfigurer{
String[]excludes=new String[]{
"/static/**",//排除靜態文件被攔截
"/wxuser/login"//其他不攔截的請求
};
public void addInterceptors(InterceptorRegistry registry){
registry.addInterceptor(WXLoginInterceptor()).addPathPatterns("/**").excludePathPatterns(excludes);
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
//排除靜態資源
registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
}
}
5.Error:(4, 40) java: 程序包com.fasterxml.jackson.annotation不存在
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
6.Caused by: java.lang.IllegalStateException: Failed to introspect Class [com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure] from ClassLoader [sun.misc.Launcher$AppClassLoader@18
將druid升級到1.1.10
7.上傳圖片的controller方法不執行
我遇到的一種原因圖片過大。
解決方法:
1.前端壓縮圖片
2.服務器將參數配置放大
3.新版本對圖片上傳配置做了調整需要帶單位(新版本默認maxFileSize=1M
)超過controller就無法接收到請求
以前properties是
##圖片上傳限制20兆
spring.servlet.multipart.maxFileSize=2
spring.servlet.multipart.maxRequestSize=10
現在需要加上單位
##圖片上傳限制20兆
spring.servlet.multipart.maxFileSize=20M
spring.servlet.multipart.maxRequestSize=200M