http://www.cnblogs.com/101key/p/5131546.html
一、配置操作系统环境变量
JAVA_HOME = C:Program Files (x86)Javajdk1.7.0_67
JBOSS_HOME = F:serverwildfly-9.0.2
classpath = %JAVA_HOME%lib ools.jar;%JAVA_HOME%libdt.jar;%JAVA_HOME%in;
PATH = %JAVA_HOME%in;%JBOSS_HOME%in;
二、添加控制台管理账号
运行 F:serverwildfly-9.0.2inadd-user.bat , 根据提示一步步创建;
三、启动服务验证初始环境正确性
运行 F:serverwildfly-9.0.2instandalone.bat
访问 http://localhost:9990/ 输入创建的用户名和密码;
四、配置项目所需数据源(本例为MS SQL Server数据库)
4.1 编辑 F:serverwildfly-9.0.2standaloneconfigurationstandalone.xml 添加数据源
<datasources>
<datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
<connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>
<datasource jndi-name="java:jboss/datasources/codewh" pool-name="codewh" enabled="true" use-java-context="true">
<connection-url>jdbc:jtds:sqlserver://127.0.0.1:1433/codewh</connection-url>
<driver>sourceforge.jtds</driver>
<security>
<user-name>sa</user-name>
<password>123</password>
</security>
</datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
<driver name="sourceforge.jtds" module="sourceforge.jtds">
<xa-datasource-class>net.sourceforge.jtds.jdbc.Driver</xa-datasource-class>
</driver>
</drivers>
</datasources>
4.2 创建数据源模块目录及文件
创建 F:serverwildfly-9.0.2modulessourceforgejtdsmain 目录
复制 jtds-1.3.0.jar 到该目录下,并创建 module.xml 文件,文件内容如下:
<?xml version="1.0" encoding="UTF-8"?> <module xmlns="urn:jboss:module:1.0" name="sourceforge.jtds"> <resources> <resource-root path="jtds-1.3.0.jar"/> </resources> <dependencies> </dependencies> </module>
JAVA 数据源获取: (DataSource) ctx.lookup("java:jboss/datasources/codewh");
五、 编辑 F:serverwildfly-9.0.2standaloneconfigurationstandalone.xml
5.1 配置项目部署位置信息
<subsystem xmlns="urn:jboss:domain:deployment-scanner:2.0"> <deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-interval="5000" runtime-failure-causes-rollback="${jboss.deployment.scanner.rollback.on.failure:false}"/> <deployment-scanner name="code" path="F:/server/deploy" scan-enabled="true" scan-interval="5000" auto-deploy-zipped="false" auto-deploy-exploded="false" deployment-timeout="100"/> </subsystem>
5.2 修改web服务端口:
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
<socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/>
<socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9993}"/>
<socket-binding name="ajp" port="${jboss.ajp.port:8009}"/>
<socket-binding name="http" port="${jboss.http.port:86}"/>
<socket-binding name="https" port="${jboss.https.port:8443}"/>
<socket-binding name="txn-recovery-environment" port="4712"/>
<socket-binding name="txn-status-manager" port="4713"/>
<outbound-socket-binding name="mail-smtp">
<remote-destination host="localhost" port="25"/>
</outbound-socket-binding>
</socket-binding-group>
5.3 设置默认访问界面:
<server name="default-server">
<http-listener name="default" socket-binding="http" redirect-socket="https"/>
<host name="default-host" alias="localhost">
<!--
<location name="/" handler="welcome-content"/>
-->
<filter-ref name="server-header"/>
<filter-ref name="x-powered-by-header"/>
</host>
</server>
<servlet-container name="default">
<jsp-config development="true"/>
<websockets/>
</servlet-container>
在项目工程增加jboss-web.xml文件(WEB-INFjboss-web.xml) 内容如下:
<?xml version="1.0" encoding="UTF-8"?> <jboss-web> <context-root>/</context-root> </jboss-web>
六、 部署项目工程文件
创建 F:serverdeploycode.war 目录后,把全部工程文件拷贝到该目录下;
创建 F:serverdeploycode.war.deployed 文件;
七、启动 F:serverwildfly-9.0.2instandalone.bat
访问 http://localhost:86/ 成功即完成全部部署工作。
八、注册系统服务(操作系统-环境变量-系统变量中须设置JAVA_HOME)
在dos下执行: