BasicDataSource被类型为UrlDecodingDataSource的不兼容bean实例覆盖

时间:2019-04-03 13:54:07

标签: java spring pivotal-cloud-foundry

我试图将我的Spring Restful Web API公开给Pivotal Cloud Foundary,我成功连接了Pivotal MySql数据库,在Local上它运行正常,但是当我在PCF中进行战争时,它抛出了异常

    nested exception is java.lang.IllegalStateException: @Bean method
 SpringBeanContainer.dataSource called as bean reference for type
 [org.apache.commons.dbcp2.BasicDataSource] but overridden by non-compatible
 bean instance of type [org.cloudfoundry.reconfiguration.org.springframework.cloud.service.relational.UrlDecodingDataSource].

我是云新手,对此我并不了解,UrlDecodingDataSource似乎试图覆盖某些内容,因此我的sessionFactory无法创建为bean。

详细日志

      [OUT] org.springframework.beans.factory.UnsatisfiedDependencyException:
     Error creating bean with name 'loginController': Unsatisfied dependency
     expressed through field 'userDetailService'; nested exception is 
    org.springframework.beans.factory.UnsatisfiedDependencyException: 
Error creating bean with name 'userDetailService': Unsatisfied dependency
 expressed through field 'uddDao'; nested exception is
 org.springframework.beans.factory.UnsatisfiedDependencyException: Error
 creating bean with name 'userDetailDaoImpl': Unsatisfied dependency expressed
 through field 'sessionFactory'; nested exception is
 org.springframework.beans.factory.BeanCreationException: Error creating bean
 with name 'sessionFactory' defined in
 com.javarnd.cc.configuration.SpringBeanContainer: Bean instantiation via
 factory method failed; nested exception is
 org.springframework.beans.BeanInstantiationException: Failed to instantiate
 [org.springframework.orm.hibernate5.LocalSessionFactoryBean]: Factory method
 'sessionFactory' threw exception; nested exception is
 java.lang.IllegalStateException: @Bean method SpringBeanContainer.dataSource
 called as bean reference for type [org.apache.commons.dbcp2.BasicDataSource]
 but overridden by non-compatible bean instance of type [org.cloudfoundry.reconfiguration.org.springframework.cloud.service.relational.UrlDecodingDataSource].
我的SpringBeanContainer中的

DataSource代码段

@Bean // Simple Bean Defination in XML
    public BasicDataSource dataSource() {
        BasicDataSource dataSource = new BasicDataSource();
        dataSource.setDriverClassName(env.getProperty(DRIVER_CLASS));
        dataSource.setUrl(env.getProperty(URL));
        dataSource.setUsername(env.getProperty(USERNAME));
        dataSource.setPassword(env.getProperty(PASSWORD));
        return dataSource;
    }

请帮助我解决或建议

0 个答案:

没有答案