我有我的带有 Beans 的配置类,如下所述
@Bean(name = "entityManagerFactory")
public LocalContainerEntityManagerFactoryBean entityManagerFactory(@Qualifier("sqlServerDataSource") DataSource dataSource) {
LocalContainerEntityManagerFactoryBean lef = new LocalContainerEntityManagerFactoryBean();
lef.setDataSource(dataSource);
lef.setJpaVendorAdapter(jpaVendorAdapter());
lef.setPackagesToScan("de.id.dih");
return lef;
}
private JpaVendorAdapter jpaVendorAdapter() {
HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter();
hibernateJpaVendorAdapter.setShowSql(true);
hibernateJpaVendorAdapter.setDatabase(Database.SQL_SERVER);
hibernateJpaVendorAdapter.setDatabasePlatform("org.hibernate.dialect.SQLServer2008Dialect");
return hibernateJpaVendorAdapter;
}
@Bean
public PlatformTransactionManager transactionManager(LocalContainerEntityManagerFactoryBean emf) {
JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setEntityManagerFactory(emf.getObject());
return transactionManager;
}
和 Maven 依赖项看起来像:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<!--<scope>provided</scope>-->
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
当我在 Spring XD 中部署模块时,出现以下异常
ERROR DeploymentsPathChildrenCache-0 server.ContainerRegistrar - Exception deploying module
java.lang.IllegalArgumentException: Cannot instantiate interface org.springframework.boot.SpringApplicationRunListener : org.springframework.boot.context.event.EventPublishingRunListener
at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:381)
at org.springframework.boot.SpringApplication.getRunListeners(SpringApplication.java:352)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:274)
at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:142)
at org.springframework.xd.module.core.SimpleModule.initialize(SimpleModule.java:203)
at org.springframework.xd.dirt.module.ModuleDeployer.deploy(ModuleDeployer.java:98)
at org.springframework.xd.dirt.module.ModuleDeployer.deployAndStore(ModuleDeployer.java:88)
at org.springframework.xd.dirt.module.ModuleDeployer.deployAndStore(ModuleDeployer.java:78)
at org.springframework.xd.dirt.server.ContainerRegistrar.deployModule(ContainerRegistrar.java:231)
at org.springframework.xd.dirt.server.ContainerRegistrar.deployJobModule(ContainerRegistrar.java:530)
at org.springframework.xd.dirt.server.ContainerRegistrar.onChildAdded(ContainerRegistrar.java:447)
at org.springframework.xd.dirt.server.ContainerRegistrar.access$800(ContainerRegistrar.java:95)
at org.springframework.xd.dirt.server.ContainerRegistrar$DeploymentListener.childEvent(ContainerRegistrar.java:826)
at org.apache.curator.framework.recipes.cache.PathChildrenCache$5.apply(PathChildrenCache.java:509)
at org.apache.curator.framework.recipes.cache.PathChildrenCache$5.apply(PathChildrenCache.java:503)
at org.apache.curator.framework.listen.ListenerContainer$1.run(ListenerContainer.java:92)
at com.google.common.util.concurrent.MoreExecutors$SameThreadExecutorService.execute(MoreExecutors.java:297)
at org.apache.curator.framework.listen.ListenerContainer.forEach(ListenerContainer.java:83)
at org.apache.curator.framework.recipes.cache.PathChildrenCache.callListeners(PathChildrenCache.java:500)
at org.apache.curator.framework.recipes.cache.EventOperation.invoke(EventOperation.java:35)
at org.apache.curator.framework.recipes.cache.PathChildrenCache$10.run(PathChildrenCache.java:762)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.IllegalArgumentException: class org.springframework.boot.context.event.EventPublishingRunListener is not assignable to interface org.springframework.boot.SpringApplicationRunListener
at org.springframework.util.Assert.isAssignable(Assert.java:369)
at org.springframework.util.Assert.isAssignable(Assert.java:352)
at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:375)
... 29 more
是否可以在 Spring XD 环境中使用带有上述 Bean 的配置类?
任何尽快的帮助将不胜感激。
谢谢