通过以下配置,我的审计日志代码在tomcat8服务器上运行良好,但当我试图在JBoss7上部署相同的代码时,它出现了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信息[org.springframework.orm.JPA.localContainerEntityManagerFactoryBean](MSC服务线程1-4)关闭持久性单元'MyPersistentUnit'的JPA EntityManagerFactory 18:56:43,057错误[org.springframework.web.Context.ContextLoader](MSC服务线程1-4)上下文初始化失败:此处
在persistence.xml
中没有EntityInfo
项。将persistence.xml
中的
替换为
。
问题内容: 我已经创建了自己的服务,并且需要注入原则EntityManager,但是我没有看到在我的服务上被调用,并且注入不起作用。 这是代码和配置: 这是我的包 我已经将.yml导入了我的应用中 当我在控制器中致电服务时 我得到一个对象(不为null),但是在UserService中为null,正如我已经提到的,从未调用过UserService上的构造函数 还有一件事,Controller和Us
我已经创建了自己的服务,需要注入doctrine EntityManager,但我看不到在我的服务上调用了,注入也不起作用。 以下是代码和配置: 这是我的包中的 我已经导入了. yml在在我的应用程序中 当我在控制器中调用服务时 我得到一个对象(不是null),但是
如何使用Spring JPA注入EntityManager对象 我使用的是spring上下文 我的dao是,注入EntityManager 我的persistence.xml 所以我收到以下错误:
问题内容: 我已经用AngularJS编写了一个服务,但是我无法使其与角度种子处理方式一起使用。 控制器代码如下: 请注意,注释掉的部分工作正常,但我想像(推荐的)第二种方式来处理它。 我得到的错误是照片是未定义的,所以我的猜测是我传递(注入)它的方法是错误的,但是我找不到正确的方法 问题答案: 您需要定义服务: 一些参考: http://docs.angularjs.org/api/angula
问题内容: Spring 是否可以在不扩展的情况下将JPA 对象注入到我的DAO类中?如果是,在这种情况下,Spring是否管理事务? 我试图使我的Spring配置尽可能简单: 问题答案: 是的,尽管它充满了陷阱,但由于JPA有点特殊。在代码中没有显式的Spring依赖关系的情况下,非常值得阅读有关注入JPA 和的文档: http://static.springsource.org/spring/
我尝试了,,和组合,但没有任何效果@注入失败maven quarkus插件构建: [错误]原因:javax。企业注射UnsatisfiedSolutionException:javax类型的未满足依赖关系。坚持不懈EntityManager和限定符[@Default] 我尝试了使用和不使用persistence.xml.我的数据源和application.properties工作正常,因为我可以注