我的两个实体管理器applicationContext.xml对应两个不同的数据库.我可以很容易地查询database1用entityManager1,但是当我尝试访问database2使用entityManager2,我没有得到任何结果.我正在使用Spring + Hibernate + JPA.
这是我的 ApplicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans default-autowire="byName"
xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<bean
class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="database" value="INFORMIX" />
<property name="showSql" value="true" />
</bean>
</property>
<property name="persistenceUnitManager" ref="persistenceUnitManager" />
<property name="persistenceUnitName" value="PU1" />
</bean>
<bean id="entityManagerFactory2"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource2" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="database" value="INFORMIX" />
<property name="showSql" …Run Code Online (Sandbox Code Playgroud) 我在我的应用程序中使用log4j作为日志框架,使用JBOSS 5作为应用程序服务器.我在应用程序的src文件夹中创建了一个log4j.properties文件.这就是我的log4j.properties的样子:
#Default log level to ERROR. Other levels are INFO and DEBUG.
log4j.rootLogger=INFO, ROOT
log4j.appender.ROOT=org.apache.log4j.RollingFileAppender
##Uncomment the next line and comment the 2nd next line when ready to deploy
log4j.appender.ROOT.File=/www/public/logs/myapp.log
##log4j.appender.ROOT.File=C:/myapp.log
log4j.appender.ROOT.MaxFileSize=100KB
#Keep 5 old files around.
log4j.appender.ROOT.MaxBackupIndex=5
log4j.appender.ROOT.layout=org.apache.log4j.PatternLayout
#Format almost same as WebSphere's common log format.
log4j.appender.ROOT.layout.ConversionPattern=[%d] %t %c %-5p - %m%n
#Optionally override log level of individual packages or classes
log4j.logger.com.webage.ejbs=INFO
Run Code Online (Sandbox Code Playgroud)
但我可以看到myapp.log从未被创建过,所以我无法看到任何日志.此外,我可以在服务器日志文件夹中的server.log文件,但它有如此多的冗长,很难跟踪那里发生了什么.所以我有两个问题:
1.为什么没有创建myapp.log.
2.你认为上面显示的log4j.property文件是否足够或者不需要在这里配置更多东西.
谢谢,
Sameer