当前正在使用 Spring Boot 2.1.7版。现在,我转到了 Spring Boot 2.2.1 RELEASE 版。当我运行我的jar文件时,它失败并显示类似错误
required a bean of type 'org.springframework.jdbc.core.jdbctemplate'
pom.xml
<dependencies>
<!-- Spring boot framework -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web-services</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
</dependency>
</dependencies>
Java类文件
@Component
public class StoredProcedureExecutor
{
@Autowired
JdbcTemplate jdbc;
}
module-context.xml
<bean id="dataSource" class="org.apache.tomcat.jdbc.pool.DataSource"
depends-on="dalConfiguration" destroy-method="close">
<property name="driverClassName" value="#{dalConfiguration.driverClassName}" />
<property name="url" value="#{dalConfiguration.url}" />
<property name="username" value="#{dalConfiguration.username}" />
<property name="password" value="#{dalConfiguration.password}" />
<property name="initialSize" value="#{dalConfiguration.poolInitialSize}" />
<property name="maxIdle" value="#{dalConfiguration.poolMaxIdle}" />
<property name="maxActive" value="#{dalConfiguration.poolMaxActive}" />
<property name="timeBetweenEvictionRunsMillis" value="1800" />
<property name="minEvictableIdleTimeMillis" value="1800" />
</bean>
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="dataSource" />
</bean>
我尝试了以下解决方案。
在
spring-boot-starter-jdbc
文件中添加了pom.xml
依赖项。删除
.m2\repository\org\springframework\spring-jdbc
并更新项目
但是仍然出现相同的错误。是否存在任何春季启动版本问题?