配置SpringWebFlow演示应用程序以使用JBoss7托管数据源
我在JBoss7服务器中配置了一个容器管理的数据源(“myDataSource”)。数据源似乎已正确部署(我已从管理控制台进行了检查)。配置SpringWebFlow演示应用程序以使用JBoss7托管数据源,spring,jboss,jboss7.x,spring-webflow,Spring,Jboss,Jboss7.x,Spring Webflow,我在JBoss7服务器中配置了一个容器管理的数据源(“myDataSource”)。数据源似乎已正确部署(我已从管理控制台进行了检查)。 我在jboss上构建并部署了Spring示例webflow primefaces showcase应用程序,该演示程序已正确部署并正常工作。 我想在演示中使用jboss数据源,但我无法让它工作。此时,我没有任何可以访问数据库的支持代码,我只想正确配置数据源 我在pom.xml中为oracle驱动程序添加了一个依赖项 <dependency> <
我在jboss上构建并部署了Spring示例webflow primefaces showcase应用程序,该演示程序已正确部署并正常工作。 我想在演示中使用jboss数据源,但我无法让它工作。此时,我没有任何可以访问数据库的支持代码,我只想正确配置数据源 我在pom.xml中为oracle驱动程序添加了一个依赖项
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.1.0.7.0</version>
</dependency>
我必须在某处添加jndi引用:
<jee:jndi-lookup id="entityManager" jndi-name="java:comp/env/persistence/myDataSource-emf"
expected-type="javax.persistence.EntityManager"/>
但我不知道在哪里。是否需要创建ApplicationContext.xml?我可以把它放在rootContext.xml中吗
我怎样才能让这两个人一起玩得开心呢
我的配置:
- JBoss7.1
- 春季3.1.2
- 弹簧腹板流量2.3.1
- 问题出在persistence.xml中
我改变了这一行:
<jta-data-source>java:/myDataSource</jta-data-source>
java:/myDataSource
致:
java:jboss/datasources/myDataSource
我将jndi查找放在servlet-context.xml中:
<jee:jndi-lookup id="entityManagerFactory" jndi-name="java:comp/env/persistence/myDataSource-emf"
expected-type="javax.persistence.EntityManagerFactory"/>
并编辑模式引用以添加jndi标记:
<?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:mvc="http://www.springframework.org/schema/mvc"
xmlns:faces="http://www.springframework.org/schema/faces"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/faces http://www.springframework.org/schema/faces/spring-faces.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd">
<jta-data-source>java:/myDataSource</jta-data-source>
<jta-data-source>java:jboss/datasources/myDataSource</jta-data-source>
<jee:jndi-lookup id="entityManagerFactory" jndi-name="java:comp/env/persistence/myDataSource-emf"
expected-type="javax.persistence.EntityManagerFactory"/>
<?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:mvc="http://www.springframework.org/schema/mvc"
xmlns:faces="http://www.springframework.org/schema/faces"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/faces http://www.springframework.org/schema/faces/spring-faces.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd">