Springboot 2.2.1RELEASE-需要类型为'org.springframework.jdbc.core.jdbctemplate'的bean

时间:2019-12-10 04:09:27

标签: spring-boot spring-data-jpa spring-jdbc

当前正在使用 Spring Boot 2.1.7版。现在,我转到了 Spring Boot 2.2.1 RELEASE 版。当我运行我的jar文件时,它失败并显示类似错误

required a bean of type 'org.springframework.jdbc.core.jdbctemplate' 

enter image description here

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并更新项目

  •   

但是仍然出现相同的错误。是否存在任何春季启动版本问题?

0 个答案:

没有答案