5、又一次boot版本和cloud版本不兼容
bug:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configurationPropertiesBeans' defined in org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration: Failed to instantiate [org.springframework.cloud.context.properties.ConfigurationPropertiesBeans]: Factory method 'configurationPropertiesBeans' threw exception with message: org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata
今天项目报错:觉得这个bug似曾相识,后来一查,还是boot版本和cloud版本不兼容的问题:
将boot设置为 2.0.6.RELEASE 版本,cloud版本为Finchley.SR2
依赖代码如下:
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.6.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent>
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Finchley.SR2</version> <type>pom</type> <scope>import</scope> </dependency>
4、JAVA版本过高
报的第二个错:
Cannot load configuration class: org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration
原来是因为java版本太高,于是把java版本设置为8.注意项目SDK也要设置为1.8
3、自动注入之@value
@value使用之,如果配置文件中没有该项配置的属性名称 报错 BeanCreationException
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mynameController': Injection of autowired dependencies failed
2、test问题
bug报错:
There are test failures. Please refer to /Users/andy_mac/CodeSpace/springboot/springboot202304/demo/target/surefire-reports for the individual test results. Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
解决措施:
test测试类中,注释掉@test注解
1、springboot版本与cloud版本与openfeign版本对应问题
bug报错:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name‘org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryConfiguration$EmbeddedTomcat’: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError:org/springframework/boot/context/properties/ConfigurationPropertiesBean
解决措施:版本要一一对应,验证可运行的版本有以下。其他版本一一对应链接:
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.10.RELEASE</version>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>2.2.0.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<version>2.2.10.RELEASE</version>
旧版本可用如下:boot 2.2.1.RELEASE
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.2.1.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <properties> <java.version>1.8</java.version> <cloud.version>Hoxton.RELEASE</cloud.version> <alibaba.version>2.2.0.RELEASE</alibaba.version> <mybatis-plus.version>3.3.1</mybatis-plus.version> <mysql.version>5.1.46</mysql.version> <swagger.version>2.7.0</swagger.version> <jwt.version>0.7.0</jwt.version> <fastjson.version>1.2.29</fastjson.version> <httpclient.version>4.5.1</httpclient.version> <easyexcel.version>2.1.1</easyexcel.version> <aliyun.version>4.1.1</aliyun.version> <oss.version>3.9.1</oss.version> <jodatime.version>2.10.1</jodatime.version> </properties>