通过以下配置,我的审计日志代码在tomcat8服务器上运行正常但是当我尝试在JBoss 7上部署它时,它给出了BeanCreationException。 我错过了什么请帮忙。 感谢。
我的persistence.xml是
enter code<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="MyPersistentUnit">
<!-- JPA Entity classes are configured here -->
<class>com.hexaview.wealthnewsmate.daotier.models</class>
<shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
<properties>
<property name="hibernate.ejb.interceptor" value="com.hexaview.wealthnewsmate.biztier.services.auditlog.AuditTableServiceImpl" />
</properties>
</persistence-unit>
</persistence>
和applicationContext.xml是
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">
<context:property-placeholder location="classpath:db-info.properties"
order="1" ignore-unresolvable="true" />
<context:property-placeholder location="classpath:email-info.properties"
order="2" ignore-unresolvable="true" />
<context:property-placeholder location="classpath:currency-pair-info.properties"
order="3" ignore-unresolvable="true" />
<!-- Declare the Interceptor -->
<mvc:interceptors>
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"
p:paramName="locale" />
</mvc:interceptors>
<!-- Declare the Resolver -->
<bean id="localeResolver"
class="org.springframework.web.servlet.i18n.SessionLocaleResolver" />
<bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basenames">
<list>
<value>authentication-messages_en_US</value>
<value>messages_en_US</value>
</list>
</property>
<property name="defaultEncoding" value="UTF-8" />
</bean>
<!-- JPA config start here -->
<jpa:repositories base-package="com.hexaview.wealthnewsmate.daotier.repo" />
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${spring.datasource.driver-class-name}" />
<property name="url" value="${spring.datasource.url}" />
<property name="username" value="${spring.datasource.username}" />
<property name="password" value="${spring.datasource.password}" />
</bean>
<bean id="jpaVendorAdapter"
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="${spring.datasource.showSQLs}" />
<property name="generateDdl" value="${spring.datasource.generateDDL}" />
<property name="database" value="${spring.datasource.type}" />
</bean>
<!-- <bean id="auditInterceptor" class="com.hexaview.wealthnewsmate.biztier.services.auditlog.AuditTableServiceImpl" /> -->
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
p:persistenceXmlLocation="classpath*:persistence.xml"
p:persistenceUnitName="MyPersistentUnit">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter" ref="jpaVendorAdapter" />
<property name="packagesToScan" value="com.hexaview.wealthnewsmate.daotier.models"/>
<!-- spring based scanning for entity classes -->
<property name="loadTimeWeaver">
<bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
<!-- <bean id="controllerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="urlMap">
<util:map>
<entry key="index" value-ref="filenameViewController" />
<entry key="demo" value-ref="filenameViewController" />
</util:map>
</property>
</bean> -->
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="${email.host}" />
<property name="port" value="${email.port}" />
<property name="username" value="${email.username}" />
<property name="password" value="${email.password}" />
<property name="javaMailProperties">
<props>
<!-- <prop key="mail.smtp.ssl.trust">smtp.mail.yahoo.com</prop>-->
<prop key="mail.smtp.ssl.enable">true</prop>
<prop key="mail.smtp.auth">true</prop>
</props>
</property>
</bean>
</beans>
详细的执行追踪就是这个
enter code18:56:43,054 WARN [org.springframework.web.context.support.XmlWebApplicationContext] (MSC service thread 1-4) Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'financeNewsController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.hexaview.framework.webtier.helpers.BaseHelper com.hexaview.framework.webtier.controllers.BaseController.baseHelper; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'baseHelper': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.hexaview.wealthnewsmate.daotier.services.entityinfo.IEntityInfoDataService com.hexaview.framework.webtier.helpers.BaseHelper.entityInfoDataService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityInfoDataService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.hexaview.wealthnewsmate.daotier.repo.entityinfo.IEntityInfoRepository com.hexaview.wealthnewsmate.daotier.services.entityinfo.EntityInfoDataServiceImpl.entityInfoRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'IEntityInfoRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not an managed type: class com.hexaview.wealthnewsmate.daotier.models.core.EntityInfo
18:56:43,056 INFO [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean](MSC服务主题1-4)关闭持久性单元的JPA EntityManagerFactory&#39; MyPersistentUnit&#39; 18:56:43,057错误[org.springframework.web.context.ContextLoader](MSC服务线程1-4)上下文初始化失败:这里
答案 0 :(得分:0)
EntityInfo
中的persistence.xml
没有条目。将<class>com.hexaview.wealthnewsmate.daotier.models</class>
替换为<class>com.hexaview.wealthnewsmate.daotier.models.core.EntityInfo</class>
中的persistence.xml
。