我正在尝试将springboot版本从1.4.5升级到2.0.7。我已经将spring-boot-starter-parent以及它对云的依赖关系更新为spring-cloud-starter-netflix-hystrix。也是Finchley.SR2的春季云版本。
pom.xml:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-
8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<springfox-version>2.5.0</springfox-version>
<spring-cloud.version>Finchley.SR2</spring-cloud.version>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.7.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-rest-webmvc</artifactId>
<version>3.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
<dependency>
<groupId>io.pivotal.spring.cloud</groupId>
<artifactId>spring-cloud-services-starter-config-
client</artifactId>
<version>2.0.3.RELEASE</version>
<type>pom</type>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
在启动tomcat上下文时出现错误。以下是我从控制台获取的日志。
正在加载类
com.mysql.jdbc.Driver'. This is deprecated. The new driver class is
com.mysql.cj.jdbc.Driver'。司机是 通过SPI自动注册并手动加载驱动程序 通常不需要上课。 2019-01-02 16:42:59.780信息14180 -[ost-startStop-1] jdbc.audit:空。返回了DataSource.unwrap(com.zaxxer.hikari.HikariDataSource类) 2019-01-02 16:42:59.855错误14180 --- [ost-startStop-1] o.s.b.web.embedded.tomcat.TomcatStarter:/ 启动Tomcat时出错 上下文。例外: org.springframework.beans.factory.BeanCreationException。信息: 创建名称为“ servletEndpointRegistrar”的bean时出错 类路径资源 / [org / springframework / boot / actuate / autoconfigure / endpoint / web / ServletEndpointManagementContextConfiguration $ WebMvcServletEndpointManagementContextConfiguration.class]: 通过工厂方法实例化Bean失败;嵌套异常为 org.springframework.beans.BeanInstantiationException:失败 实例化 [org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]: 工厂方法“ servletEndpointRegistrar”抛出异常;嵌套的 异常是org.springframework.beans.factory.BeanCreationException: 创建在类路径中定义的名称为“ healthEndpoint”的bean时出错 资源 [org / springframework / boot / actuate / autoconfigure / health / HealthEndpointConfiguration.class]: 通过工厂方法实例化Bean失败;嵌套异常为 org.springframework.beans.BeanInstantiationException:失败 实例化[org.springframework.boot.actuate.health.HealthEndpoint]: 工厂方法'healthEndpoint'抛出异常;嵌套异常为 org.springframework.beans.factory.BeanCreationException:错误 用名字创建bean 'org.springframework.boot.actuate.autoconfigure.jdbc.DataSourceHealthIndicatorAutoConfiguration': 通过构造函数实例化Bean失败;嵌套异常为 org.springframework.beans.BeanInstantiationException:失败 实例化 [org.springframework.boot.actuate.autoconfigure.jdbc.DataSourceHealthIndicatorAutoConfiguration $$ EnhancerBySpringCGLIB $$ 4d404129]: 构造函数抛出异常;嵌套异常为 org.springframework.beans.factory.BeanCreationException:错误 创建名称为“ dataSource”的bean:FactoryBean的后处理 单例对象失败;嵌套异常为 java.lang.ClassCastException: net.sf.log4jdbc.sql.jdbcapi.DataSourceSpy无法强制转换为 com.zaxxer.hikari.HikariConfig 2019-01-02 16:43:00.016 INFO 14180 --- [main] o.apache.catalina.core.StandardService:正在停止 服务[Tomcat]