Весна 3.1: DataSource не заставляет @configuration Class

Я использую Spring MVC 3.1.0M2 и пытаясь переместить мой Конфиги к Java Beans. Но я столкнулся с последующей ошибкой:

2011-09-14 18: 43: 42.301: Warn: /: недоступен org.springframework.beans.factory.beancreationexception: ошибка Создание компонента с именем 'org.springframework.transaction.annotation.proxytransactionmanagement.croxgrade # 0 ': инъекция заложенных зависимостей не удалось; Вложенное исключение является org.springframework.beans.foectory.beancrationionexception: не смогли автосистему: void org.springframework.transaction.annotation.abstracttransactionmanagementConfiguration.Coletconfigurers (java.util.collection); Вложенное исключение - org.springframework.beans.fovertory.beancreationexception: Ошибка создания бобов с именем «EntityManagerFactory» Определена в классе Ru.mystamps.web.config.dbconfig. Вложенное исключение является org.springframework.beans.fovertory.beandefinitystoreexception: фабричный метод [public org.springframework.orm.jpa.localcontaineanentitymanagerfactorybean ru.mystamps.web.config.dbconfig.entitymanagerfactory ()] бросил исключение; Вложенное исключение java.lang.illegalargumentException: DataSource не должен быть нулевым

сопоставлением из web.xml :

<context-param>
    <param-name>spring.profiles.default</param-name>
    <param-value>dev</param-value>
</context-param>

<servlet>
    <servlet-name>spring</servlet-name>
    <servlet-class>
        org.springframework.web.servlet.DispatcherServlet
    </servlet-class>
    <init-param>
        <param-name>contextClass</param-name>
        <param-value>
            org.springframework.web.context.support.AnnotationConfigWebApplicationContext
        </param-value>
    </init-param>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            ru.mystamps.web.config.MvcConfig,
            ru.mystamps.web.config.DbConfig
        </param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

dbconfig.java :

@Configuration
@EnableTransactionManagement
@ImportResource("classpath:spring/datasource.xml")
public class DbConfig {

    @Autowired
    private DataSource dataSource;

    @Bean
    public JpaVendorAdapter jpaVendorAdapter() {
        final HibernateJpaVendorAdapter jpaVendorAdapter =
            new HibernateJpaVendorAdapter();

        jpaVendorAdapter.setDatabasePlatform(dialectClassName);
        jpaVendorAdapter.setShowSql(showSql);

        return jpaVendorAdapter;
    }

    @Bean
    public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
        final LocalContainerEntityManagerFactoryBean entityManagerFactory =
            new LocalContainerEntityManagerFactoryBean();

        entityManagerFactory.setJpaVendorAdapter(jpaVendorAdapter());
        entityManagerFactory.setDataSource(dataSource);

        final Map<String, String> jpaProperties = new HashMap<String, String>();
        jpaProperties.put("hibernate.format_sql", formatSql);
        jpaProperties.put("hibernate.connection.charset", "UTF-8");
        jpaProperties.put("hibernate.hbm2ddl.auto", hbm2ddl);
        entityManagerFactory.setJpaPropertyMap(jpaProperties);

        return entityManagerFactory;
    }

    @Bean
    public PlatformTransactionManager transactionManager() {
        final JpaTransactionManager transactionManager =
            new JpaTransactionManager();

        transactionManager.setEntityManagerFactory(entityManagerFactory().getObject());

        return transactionManager;
    }

    ...
}

Spring / DataSource.xml :

<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:jdbc="http://www.springframework.org/schema/jdbc"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.1.xsd
    http://www.springframework.org/schema/jdbc
    http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd">

    <context:property-placeholder location="classpath:spring/database.properties" />

    <beans profile="dev">
        <bean id="dataSource"
            class="org.apache.commons.dbcp.BasicDataSource"
            destroy-method="close">
            <property name="driverClassName" value="${db.driverClassName}" />
            <property name="url" value="${db.url}" />
            <property name="username" value="${db.username}" />
            <property name="password" value="${db.password}" />
        </bean>
    </beans>

    <beans profile="test">
        <jdbc:embedded-database id="dataSource" type="HSQL">
            <jdbc:script location="classpath:test-data.sql" />
        </jdbc:embedded-database>
    </beans>

</beans>

Я ожидаю, что фасоль DataSource будет создан после импорта DataSource.xml , но я всегда получил эту ошибку.

TIA

8
задан Venki WAR 4 May 2018 в 05:41
поделиться