我有一个包含依赖项JAR的WAR。 JAR包含跨领域的问题,也是我写的。我正在使用Spring 4.2.3和Spring-data-jpa 1.9.1,我的配置是基于注释的。我部署到Wildfly 10.1.0。
JAR编译得很好,我将它安装到我当地的Maven Repo。从WAR中,JAR作为依赖项包含在内。到目前为止一切都很好。
在WAR的Spring配置文件中,我导入Spring配置 JAR的文件。
现在,当我有正常的Spring Beans(服务或组件)时,一切正常,Spring会在我的JAR中找到并解析所有依赖项和Spring Beans,然后我可以从WAR中的代码调用它。
但是,只要我添加一个Repository和一个Entity,Spring就找不到Entity,随后我的WAR编译但是它没有部署。我必须注意,如果我直接将JAR代码放在我的WAR中,所有这些都有效。我想我错过了一个配置,但我不确定在哪里可以看。
非常感谢任何帮助。代码和堆栈跟踪如下:
在部署时,我收到以下错误: 创建名为'synapseRepo'的bean时出错:init方法的调用失败;嵌套异常是java.lang.IllegalArgumentException:不是托管类型:class hyphen.synapse.data.model.Role
所以,这个错误很简单,但是我不知道我还缺少什么才能让Spring了解我的实体。
感谢。
JAR配置代码:
package hyphen.synapse.data.repo;
import hyphen.synapse.data.model.*;
import org.springframework.data.repository.*;
public interface SynapseRepo extends CrudRepository<Role, Long> {
}
存储库的JAR代码:
package hyphen.synapse.data.model;
import javax.persistence.*;
@Entity
@Table(name = "ROLE")
public class Role extends SynapseBaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
@Column(name = "NAME")
private String name;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
JAR实体代码:
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories("hyphen.cmd.data")
@PropertySource("classpath:application.properties")
@Import(hyphen.synapse.app.config.SynapseApplicationConfig.class)
public class ApplicationConfig {
...
}
配置的WAR代码:
package hyphen.synapse.data.dao;
import ...;
@Service
public class SynapseDao {
@Inject
private SynapseRepo synapseRepo;
@Inject
private EmailService emailService;
注射用WAR代码:
public interface SynapseRepo extends CrudRepository<Role, Long> ...
正如旁注所示,EmailService也在JAR中定义,它正确地自动装配。
以下代码行导致错误:
2017-02-16 22:38:19,666 WARN [org.springframework.web.context.support.XmlWebApplicationContext] (ServerService Thread Pool -- 218) Exception encountered during context initialization - cancelling refresh at
tempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'synapseServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.f
actory.BeanCreationException: Could not autowire field: private hyphen.synapse.data.dao.SynapseDao hyphen.synapse.business.service.impl.SynapseServiceImpl.synapseDao; nested exception is org.springframework.
beans.factory.BeanCreationException: Error creating bean with name 'synapseDao': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could
not autowire field: private hyphen.synapse.data.repo.SynapseRepo hyphen.synapse.data.dao.SynapseDao.synapseRepo; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating b
ean with name 'synapseRepo': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not an managed type: class hyphen.synapse.data.model.Role
2017-02-16 22:38:19,666 ERROR [org.springframework.web.servlet.DispatcherServlet] (ServerService Thread Pool -- 218) Context initialization failed: org.springframework.beans.factory.BeanCreationException: Er
ror creating bean with name 'synapseServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private hy
phen.synapse.data.dao.SynapseDao hyphen.synapse.business.service.impl.SynapseServiceImpl.synapseDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'synapseDao': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private hyphen.synapse.data.repo.SynapseRepo
hyphen.synapse.data.dao.SynapseDao.synapseRepo; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'synapseRepo': Invocation of init method failed; nes
ted exception is java.lang.IllegalArgumentException: Not an managed type: class hyphen.synapse.data.model.Role
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:838)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)
at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:667)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:633)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:681)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:552)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:493)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
at javax.servlet.GenericServlet.init(GenericServlet.java:244)
at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117)
at org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:78)
at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:103)
at io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:250)
at io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:133)
at io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:546)
at io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:517)
at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:559)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:101)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:82)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private hyphen.synapse.data.dao.SynapseDao hyphen.synapse.business.service.impl.SynapseServiceImpl.synapseDao; ne
sted exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'synapseDao': Injection of autowired dependencies failed; nested exception is org.springframework.bean
s.factory.BeanCreationException: Could not autowire field: private hyphen.synapse.data.repo.SynapseRepo hyphen.synapse.data.dao.SynapseDao.synapseRepo; nested exception is org.springframework.beans.factory.B
eanCreationException: Error creating bean with name 'synapseRepo': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not an managed type: class hyphen.synapse.data.mod
el.Role
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
... 41 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'synapseDao': Injection of autowired dependencies failed; nested exception is org.springframework.beans.facto
ry.BeanCreationException: Could not autowire field: private hyphen.synapse.data.repo.SynapseRepo hyphen.synapse.data.dao.SynapseDao.synapseRepo; nested exception is org.springframework.beans.factory.BeanCrea
tionException: Error creating bean with name 'synapseRepo': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not an managed type: class hyphen.synapse.data.model.Role
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545)
... 43 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private hyphen.synapse.data.repo.SynapseRepo hyphen.synapse.data.dao.SynapseDao.synapseRepo; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'synapseRepo': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not an managed
type: class hyphen.synapse.data.model.Role
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
... 54 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'synapseRepo': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not
an managed type: class hyphen.synapse.data.model.Role
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545)
... 56 more
Caused by: java.lang.IllegalArgumentException: Not an managed type: class hyphen.synapse.data.model.Role
at org.hibernate.jpa.internal.metamodel.MetamodelImpl.managedType(MetamodelImpl.java:219)
at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.<init>(JpaMetamodelEntityInformation.java:68)
at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getEntityInformation(JpaEntityInformationSupport.java:67)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:152)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:99)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:81)
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:185)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:251)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:237)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:92)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
... 66 more
2017-02-16 22:38:19,666 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 218) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./masterdatamanager: org.
jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./masterdatamanager: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 's
ynapseServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private hyphen.synapse.data.dao.SynapseD
ao hyphen.synapse.business.service.impl.SynapseServiceImpl.synapseDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'synapseDao': Injection of au
towired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private hyphen.synapse.data.repo.SynapseRepo hyphen.synapse.data.dao.Synaps
eDao.synapseRepo; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'synapseRepo': Invocation of init method failed; nested exception is java.lang.Ill
egalArgumentException: Not an managed type: class hyphen.synapse.data.model.Role
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:85)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'synapseServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.bea
ns.factory.BeanCreationException: Could not autowire field: private hyphen.synapse.data.dao.SynapseDao hyphen.synapse.business.service.impl.SynapseServiceImpl.synapseDao; nested exception is org.springframew
ork.beans.factory.BeanCreationException: Error creating bean with name 'synapseDao': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: C
ould not autowire field: private hyphen.synapse.data.repo.SynapseRepo hyphen.synapse.data.dao.SynapseDao.synapseRepo; nested exception is org.springframework.beans.factory.BeanCreationException: Error creati
ng bean with name 'synapseRepo': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not an managed type: class hyphen.synapse.data.model.Role
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:838)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)
at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:667)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:633)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:681)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:552)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:493)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
at javax.servlet.GenericServlet.init(GenericServlet.java:244)
at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117)
at org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:78)
at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:103)
at io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:250)
at io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:133)
at io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:546)
at io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:517)
at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:559)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:101)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:82)
... 6 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private hyphen.synapse.data.dao.SynapseDao hyphen.synapse.business.service.impl.SynapseServiceImpl.synapseDao; ne
sted exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'synapseDao': Injection of autowired dependencies failed; nested exception is org.springframework.bean
s.factory.BeanCreationException: Could not autowire field: private hyphen.synapse.data.repo.SynapseRepo hyphen.synapse.data.dao.SynapseDao.synapseRepo; nested exception is org.springframework.beans.factory.B
eanCreationException: Error creating bean with name 'synapseRepo': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not an managed type: class hyphen.synapse.data.mod
el.Role
Spring无法自动装入实体,在本例中为Role。我也知道Role不包含任何Spring注释。但是,我在WAR中使用了完全相同的代码并且它工作正常,但是使用包含在依赖项JAR中的代码从WAR调用它似乎有问题。
栈跟踪:
#
答案 0 :(得分:1)
您的SynapseRepo
和CommandRepo
界面应具有@Repository
注释。
然而,问题的根源在于您的WAR文件中有JPA配置,JAR中有JPA配置。因为名称,属性文件等会导致bean相互重叠。你需要花时间让它们与众不同。您可以按照https://stackoverflow.com/a/19976132/724835
上的说明操作