1.Create DataSource in WEB-INF/, filename: mysql-ds.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- See http://www.jboss.org/community/wiki/Multiple1PC for information about local-tx-datasource -->
<!-- $Id: mysql-ds.xml 88948 2009-05-15 14:09:08Z jesper.pedersen $ -->
<!-- Datasource config for MySQL using 3.0.9 available from:
http://www.mysql.com/downloads/api-jdbc-stable.html
-->
<datasources>
<local-tx-datasource>
<jndi-name>MySqlDS</jndi-name>
<connection-url>jdbc:mysql://localhost/struts-tutorial?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf-8</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>root</user-name>
<password></password>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
<!-- should only be used on drivers after 3.22.1 with "ping" support
<valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>
-->
<!-- sql to call when connection is created
<new-connection-sql>some arbitrary sql</new-connection-sql>
-->
<!-- sql to call on an existing pooled connection when it is obtained from pool - MySQLValidConnectionChecker is preferred for newer drivers
<check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
-->
<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
<metadata>
<type-mapping>mySQL</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>
2. create WEB-INF/jboss-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<security-domain flushOnSessionInvalidation="false"/>
<context-root>/struts-tutorial</context-root>
<class-loading>
<loader-repository>org.yy:loader=ejb3
<loader-repository-config>java2ParentDelegation=false</loader-repository-config>
</loader-repository>
</class-loading>
</jboss-web>
3.create META-INF/persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.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_1_0.xsd">
<persistence-unit name="StrutsTutorial" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/MySqlDS</jta-data-source>
<class>org.yy.tutorial.model.User</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<!--<property name="hibernate.connection.username" value="root"/>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.connection.password" value=""/>
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/struts-tutorial"/>-->
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
<property name="jboss.entity.manager.factory.jndi.name" value="java:/StrutsTutorial"/> <!-- NOTE -->
</properties>
</persistence-unit>
</persistence>
4.config Application.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:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd">
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:jdbc.properties</value>
</list>
</property>
</bean>
<context:component-scan base-package="org.yy.tutorial.action" resource-pattern="*">
</context:component-scan> <!-- there is bug in JBOSS5 AS -->
<tx:annotation-driven transaction-manager="transactionManager" />
<!-- <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="${jdbc.driverClassName}" />
<property name="jdbcUrl" value="${jdbc.url}" />
<property name="properties">
<props>
<prop key="c3p0.acquire_increment">5</prop>
<prop key="c3p0.idle_test_period">100</prop>
<prop key="c3p0.max_size">100</prop>
<prop key="c3p0.max_statements">0</prop>
<prop key="c3p0.min_size">10</prop>
<prop key="user">${jdbc.username}</prop>
<prop key="password">${jdbc.password}</prop>
</props>
</property>
</bean>-->
<jee:jndi-lookup id="dataSource" jndi-name="java:/MySqlDS" />
<jee:jndi-lookup id="entityManagerFactory" jndi-name="java:/StrutsTutorial"/> <!-- the jndi name is same to persistence.xml definition in properties section. -->
<!-- <bean id="persistenceUnitManager" class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
<property name="persistenceXmlLocation" value="classpath:META-INF/persistence.xml" />
<property name="defaultDataSource" ref="dataSource" />
</bean>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitManager" ref="persistenceUnitManager"/>
<property name="jpaDialect">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />
</property>
<property name="jpaProperties">
<value>
hibernate.cache.provider_class=org.hibernate.cache.NoCacheProvider
hibernate.show_sql=true
hibernate.hbm2ddl.auto=create-drop
hibernate.dialect=${hibernate.dialect}
</value>
</property>
</bean>-->
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManagerName" value="java:/TransactionManager"/> <!-- JBOSS JTA transaction manager jndi name -->
<property name="userTransactionName" value="UserTransaction"/>
</bean>
<!-- <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager" >
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>-->
<bean id="userDao" class="org.yy.tutorial.dao.UserDAOImpl" >
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
</beans>
ref: http://www.swview.org/node/214
分享到:
相关推荐
How To Deploy Kamailio on Linux
How to Deploy UI5 Applciation on the FIORI Launchpad
How to deploy ASPX MVC on IIS5.1
How to Deploy the software Update on SCCM 2007.docx
信息安全_数据安全_How to Deploy Secure Technologie 云安全 安全测试 安全设计 安全建设 漏洞分析
maven deploy the local file to a remote server. 1.config your pom.xml; 2.config your setting.xml; 3.execte cmd --- mvn deploy
NET5Jenkins_Bat Deploy IIS Web
how to identify,develop,deploy,and connect talents when companies transform to global integrated enterprise the case of advantech
关于ASP.NET Core 2.0的一本小书。 The Little ASP.NET Core Book is structured as a tutorial. You'll build a to-do app from start to finish and learn: ...How to deploy the app to the web
how to prepare and deploy a Java application
Today, JavaScript is taking the world by storm. Having logic shared between your JavaScript frontend and backend ... It also contains a few recipes on how to deploy your app to a cloud hosting service.
Moving on to the examples, we’ll look at how to deploy the “Duke’s Bank” application from the Sun J2EE Tutorial. This will let you see JBoss in action as quickly as possible and also gives you a ...
By the end of the journey, you will learn how to package an app and deploy it to app markets. App Inventor 2 Essentials prepares you to amass a resource of skills, knowledge and experience to become ...
5.远程删除文件D:\jboss\server\default\deploy\management\myname.war\index.jsp文件 java -jar jboss_exploit_fat.jar -i ...
Learn to deploy your web applications in new environments such as the cloud and Docker Book Description The ability to develop web applications that are highly efficient but also easy to maintain has ...
Finally, we’ll learn how to deploy the application to a virtual server, and install custom domains and SSL certificates. It is my hope that by the time you are finished reading this book, you’ll ...
You will learn everything you need to know in order to use OpenShift to develop and deploy applications in the cloud as well as how to deploy your very own OpenShift Origin-based Platform-as-a-Service...
Eclipse Rich Ajax Platform: Bringing Rich Client to the Web Paperback: 148 pages Publisher: Apress; 1 edition (December 29, 2008) Language: English ISBN-10: 1430218835 ISBN-13: 978-1430218838 ...