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
在开始使用JBoss之前,确保系统已安装JDK是非常重要的,因为JBoss是纯Java的Web应用服务器,依赖于JDK来运行。官方下载地址为http://labs.jboss.com/jbossas/downloads/,你可以在这里获取最新的JBoss应用服务器版本...
maven deploy the local file to a remote server. 1.config your pom.xml; 2.config your setting.xml; 3.execte cmd --- mvn deploy
在部署 Jboss 项目时,需要将 war 文件解压到 Jboss 服务器的部署目录下,例如 D:\jboss-5.1.0.GA\server\default\deploy 下。然后,需要配置 Jboss 服务器的配置文件,例如 server.xml、oracle-ds.xml 等文件。 五...
- **独立部署**:尽管通常作为JBoss AS的一部分,但JBoss Web也可以单独部署,作为轻量级的Web服务器使用。 **4. 安装与配置** - **解压部署**:"jboss-web-2.1.0.GA.zip"是一个绿色包,无需安装,解压缩后即可...
关于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
6. **SSH部署**:除了直接将WAR文件放入deploy目录,还可以通过JBoss的SSH接口进行远程部署。这需要配置SSH访问权限,并使用`jboss-cli.sh`或类似的工具执行部署命令。 7. **JBPM集成**:如果项目中使用了JBPM工作...
Gather_how_to_deploy_tensorflow_models_as_much_I_c_Gather-Tensorflow-Serving
- 打开`C:\jboss-eap-4.3\jboss-as\server\production\deploy\management\console-mgr.sar\web-console.war\WEB-INF\jboss-web.xml`文件,检查是否存在如下配置: ```xml <security-domain>ManagementRealm ``` ...
3. **部署应用**:将整个WEB应用(包括`WEB-INF`目录和`jboss-web.xml`)打包成WAR文件,然后将此WAR文件放入JBoss的`deploy`目录下。或者,如果你使用的是JBoss AS7或EAP 6及更高版本,可能需要将应用放在`...
JBoss Application Server 5(简称JBoss AS 5)是一款开源的Java EE应用服务器,由Red Hat公司维护。它提供了一个用于部署和管理企业级Java应用程序的平台。JBoss AS 5是基于EJB 3.0规范的,支持Servlet 2.5和JSP ...
当时自己安装vs2012时 webdeploy3.0安装失败了 自己在搞了半天才找到这个 希望对大家有用吧
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 ...
WebDeploy,全称为Microsoft Web Deploy,是一款由微软公司开发的强大的自动化部署工具,主要用于简化和加速Web应用程序在IIS(Internet Information Services)服务器上的发布过程。该工具特别适用于开发者和系统...
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 ...