合并bean定义的后处理失败;嵌套异常是java.lang.IllegalStateException

时间:2018-01-25 03:50:27

标签: java spring

这是我的OffersDao课程

package com.spring.dao;

import java.sql.*;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Component;

@Component
public class OffersDao {


private NamedParameterJdbcTemplate jdbc;

    @Autowired
    public void setDataSource(DataSource jdbc) {
        this.jdbc=new NamedParameterJdbcTemplate(jdbc);
    }
}

当我没有自动装配以下部分时,我的应用程序工作正常,否则它会给我上述错误

这是我的spring context xml文件

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:jee="http://www.springframework.org/schema/jee"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.3.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd">


    <context:annotation-config></context:annotation-config>
    <context:component-scan base-package="com.spring.dao"></context:component-scan>

    <jee:jndi-lookup jndi-name="jdbc/TestDB" id="dataSource"
        expected-type="javax.sql.DataSource">
    </jee:jndi-lookup>


</beans>

如果有人能告诉我为什么会这样。 此外还有Maven项目。

0 个答案:

没有答案