小编Lee*_*lla的帖子

没有定义[javax.persistence.EntityManagerFactory]类型的唯一bean:期望的单个bean但找到了2

EntityManager为两个不同的数据库定义了两个bean.每个EntityManagerbean都指一个唯一的,各自<persistence-unit/>定义的persistence.xml.

Spring 2.x使用相同的代码和配置.当我升级到Spring 3时,我在服务器中部署应用程序时看到以下异常:

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [javax.persistence.EntityManagerFactory] is defined: expected single bean but found 2

有人遇到过这个问题吗?升级到Spring 3时我错过了什么吗?我真的很感激任何回复.

我正在使用带有Hibernate和JPA的Spring 3.

问题不是含糊不清; 我正在声明两个EntityManagerFactorybean并按如下方式注入它们:

  <bean id="oracleJpaTemplate" class="org.springframework.orm.jpa.JpaTemplate">
   <property name="entityManagerFactory" ref="entityManagerFactory"></property>
  </bean>

  <bean id="sqlJpaTemplate" class="org.springframework.orm.jpa.JpaTemplate">
   <property name="entityManagerFactory" ref="sqlEntityManagerFactory"></property>
  </bean>
Run Code Online (Sandbox Code Playgroud)

这是完整的堆栈跟踪:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.flex.core.io.JpaHibernateConfigProcessor#0': Invocation of init method failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [javax.persistence.EntityManagerFactory] is defined: expected single …
Run Code Online (Sandbox Code Playgroud)

spring hibernate jpa

6
推荐指数
2
解决办法
2万
查看次数

用Java获取防火墙后面的客户端的实际IP地址

我需要在我的Web应用程序中为特定用例提供客户端的IP地址/机器名称/ Mac地址.使用request.getRemoteHost()/request.getRemoteAddr()我获取网络防火墙的详细信息而不是实际的客户端计算机.我也尝试访问请求标头 - X-Forwarded-For正如许多答案中所建议的那样.但它总是以空的形式返回.我无法控制代理服务器/防火墙服务器将其配置为添加标头,因为它们是由客户控制的.

是否有任何其他API在Java或javascript中检索请求的原始客户端IP.

任何帮助是极大的赞赏...

javascript java networking

5
推荐指数
1
解决办法
1183
查看次数

标签 统计

hibernate ×1

java ×1

javascript ×1

jpa ×1

networking ×1

spring ×1