我添加了具有Id-dataSource的 spring bean ,并添加了Oracle DB配置的属性,还添加了通用数据库配置,它引用了该bean。
<spring:beans>
<spring:bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" name="Bean">
<spring:property name="url" value="${oracleAQ.url}"/>
<spring:property name="username" value="${oracleAQ.userName}"/>
<spring:property name="password" value="${oracleAQ.password}"/>
<spring:property name="initialSize" value="10"/>
<spring:property name="maxActive" value="50"/>
<spring:property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
</spring:bean>
</spring:beans>
<db:generic-config name="Generic_Database_Configuration" dataSource-ref="dataSource" doc:name="Generic Database Configuration"/>
我为oracle db添加的依赖项是ojdbc8和commons-dbcp
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc8</artifactId>
<version>12.2.0.1</version>
</dependency>
但是,在运行该项目时,我看到类似
的错误org.mule.module.launcher.DeploymentInitException:NoSuchBeanDefinitionException:未定义名为“ dataSource”的bean 在org.mule.module.launcher.application.DefaultMuleApplication.init(DefaultMuleApplication.java:212)〜[mule-module-launcher-3.8.4.jar:3.8.4] 在org.mule.module.launcher.artifact.ArtifactWrapper $ 2.execute(ArtifactWrapper.java:63)〜[mule-module-launcher-3.8.4.jar:3.8.4] 在org.mule.module.launcher.artifact.ArtifactWrapper.executeWithinArtifactClassLoader(ArtifactWrapper.java:136)〜[mule-module-launcher-3.8.4.jar:3.8.4] 在org.mule.module.launcher.artifact.ArtifactWrapper.init(ArtifactWrapper.java:58)〜[mule-module-launcher-3.8.4.jar:3.8.4] 在org.mule.module.launcher.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:25)〜[mule-module-launcher-3.8.4.jar:3.8.4] 在org.mule.module.launcher.DefaultArchiveDeployer.redeploy(DefaultArchiveDeployer.java:463)〜[mule-module-launcher-3.8.4.jar:3.8.4] 在org.mule.module.launcher.DeploymentDirectoryWatcher.redeployModifiedArtifacts(DeploymentDirectoryWatcher.java:562)〜[mule-module-launcher-3.8.4.jar:3.8.4] 在org.mule.module.launcher.DeploymentDirectoryWatcher.redeployModifiedApplications(DeploymentDirectoryWatcher.java:539)〜[mule-module-launcher-3.8.4.jar:3.8.4] 在org.mule.module.launcher.DeploymentDirectoryWatcher.run(DeploymentDirectoryWatcher.java:352)〜[mule-module-launcher-3.8.4.jar:3.8.4] 在java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:511)〜[?:1.8.0_181] 在java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)〜[?:1.8.0_181] 在java.util.concurrent.ScheduledThreadPoolExecutor $ ScheduledFutureTask.access $ 301(ScheduledThreadPoolExecutor.java:180)〜[?:1.8.0_181] 在java.util.concurrent.ScheduledThreadPoolExecutor $ ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)〜[?:1.8.0_181] 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)[?:1.8.0_181] 在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:624)[?:1.8.0_181] 在java.lang.Thread.run(Thread.java:748)[?:1.8.0_181] 原因:org.mule.api.config.ConfigurationException:创建名称为'_muleNotificationManager'的bean时出错:FactoryBean在对象创建时抛出异常;嵌套的异常是org.springframework.beans.factory.BeanCreationException:创建名称为'Generic_Database_Configuration'的bean时出错:设置bean属性'dataSource'时无法解析对bean'dataSource'的引用;嵌套的异常是org.springframework.beans.factory.NoSuchBeanDefinitionException:未定义名为“ dataSource”的bean ,请查找所附的屏幕快照NoSuchBeanDefinitionException
我无法找到解决方案。谁能帮我解决这个问题。
答案 0 :(得分:0)
您可以尝试将name
从“ Bean”更改为“ dataSource”吗?我认为这是两个标识符引起的。