WildFly部署项目
一、下载
在浏览器地址栏输入https://www.wildfly.org/,打开WildFly官网,点击other versions选择版本,因为开发环境是jdk1.8,部署环境是Windows,所以这里我选择的是 “Java EE Full & Web Distribution”项对应的ZIP版本 ,点击下载即可,如果下载较慢可以用迅雷试试。
将下载好的压缩包解压,得到如下目录:
主要关注bin目录和standalone目录,其中bin目录里有许多和软件相关的脚本,启动脚本也位于其中,standalone目录下有许多xml文件可供启动时选择,而在readme.txt中也有英文文档。
bin目录下重点关注前缀为add-user和standalone的脚本和配置文件,其中add-user.bat和add-user.sh分别是Windows和Linux下的添加用户的脚本,standalone.bat和standalone.sh分别是Windows和Linux下的启动脚本。
如果服务器中还有其它jdk版本的项目,可以在Stand alone.conf.bat中修改jdk版本,具体操作与Tomcat下修改jdk版本相同。将下图中的两处注释取消,换成自己电脑的jdk路径即可。
二、安装
打开解压目录下的standalone目录,进入configuration目录,重点关注standalone.xml文件,这个文件主要用于WildFly的配置,类似于Tomcat中的server.xml文件。
打开standalone.xml文件,拉到最下面
<socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/>
9990是管理后台端口,8080是项目端口。
<socket-binding name="http" port="${jboss.http.port:8080}"/>
双击bin目录下的standalone.bat,启动管理后台
Calling "F:\Desktop\wildfly-14.0.0.Final\bin\standalone.conf.bat"
Setting JAVA property to "G:\Java\jdk1.8.0_211\bin\java"
===============================================================================JBoss Bootstrap EnvironmentJBOSS_HOME: "F:\Desktop\wildfly-14.0.0.Final"JAVA: "G:\Java\jdk1.8.0_211\bin\java"JAVA_OPTS: "-Dprogram.name=standalone.bat -Xms64M -Xmx512M -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman "===============================================================================15:29:33,197 INFO [org.jboss.modules] (main) JBoss Modules version 1.8.6.Final
15:29:34,094 INFO [org.jboss.msc] (main) JBoss MSC version 1.4.3.Final
15:29:34,106 INFO [org.jboss.threads] (main) JBoss Threads version 2.3.2.Final
15:29:34,242 INFO [org.jboss.as] (MSC service thread 1-3) WFLYSRV0049: WildFly Full 14.0.0.Final (WildFly Core 6.0.1.Final) starting
15:29:35,154 INFO [org.wildfly.security] (ServerService Thread Pool -- 4) ELY00001: WildFly Elytron version 1.6.0.Final
15:29:35,583 INFO [org.jboss.as.controller.management-deprecated] (Controller Boot Thread) WFLYCTL0028: Attribute 'security-realm' in the resource at address '/core-service=management/management-interface=http-interface' is deprecated, and may be removed in a future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
15:29:35,610 INFO [org.jboss.as.controller.management-deprecated] (ServerService Thread Pool -- 29) WFLYCTL0028: Attribute 'security-realm' in the resource at address '/subsystem=undertow/server=default-server/https-listener=https' is deprecated, and may be removed in a future version. See the attribute description in the output of the read-resource-description operation to learn more about the deprecation.
15:29:35,661 INFO [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0039: Creating http management service using socket-binding (management-http)
15:29:35,682 INFO [org.xnio] (MSC service thread 1-1) XNIO version 3.6.5.Final
15:29:35,694 INFO [org.xnio.nio] (MSC service thread 1-1) XNIO NIO Implementation Version 3.6.5.Final
15:29:35,752 INFO [org.jboss.remoting] (MSC service thread 1-8) JBoss Remoting version 5.0.8.Final
15:29:35,776 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 41) WFLYJCA0004: Deploying JDBC-compliant driver class org.h2.Driver (version 1.4)
15:29:35,812 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 48) WFLYCLINF0001: Activating Infinispan subsystem.
15:29:35,864 INFO [org.wildfly.extension.io] (ServerService Thread Pool -- 49) WFLYIO001: Worker 'default' has auto-configured to 8 core threads with 64 task threads based on your 4 available processors
15:29:35,864 WARN [org.jboss.as.txn] (ServerService Thread Pool -- 68) WFLYTX0013: The node-identifier attribute on the /subsystem=transactions is set to the default value. This is a danger for environments running multiple servers. Please make sure the attribute value is unique.
15:29:35,870 INFO [org.jboss.as.naming] (ServerService Thread Pool -- 60) WFLYNAM0001: Activating Naming Subsystem
15:29:35,871 INFO [org.jboss.as.jaxrs] (ServerService Thread Pool -- 50) WFLYRS0016: RESTEasy version 3.6.1.Final
15:29:35,871 INFO [org.wildfly.extension.microprofile.config.smallrye._private] (ServerService Thread Pool -- 57) WFLYCONF0001: Activating WildFly MicroProfile Config Subsystem
15:29:35,959 INFO [org.jboss.as.connector] (MSC service thread 1-5) WFLYJCA0009: Starting JCA Subsystem (WildFly/IronJacamar 1.4.11.Final)
15:29:36,014 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-5) WFLYJCA0018: Started Driver service with driver-name = h2
15:29:35,931 INFO [org.jboss.as.jsf] (ServerService Thread Pool -- 55) WFLYJSF0007: Activated the following JSF Implementations: [main]
15:29:35,920 INFO [org.jboss.as.naming] (MSC service thread 1-6) WFLYNAM0003: Starting Naming Service
15:29:35,914 INFO [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0003: Undertow 2.0.13.Final starting
15:29:35,913 INFO [org.jboss.as.mail.extension] (MSC service thread 1-4) WFLYMAIL0002: Unbound mail session [java:jboss/mail/Default]
15:29:35,900 INFO [org.wildfly.extension.microprofile.health.smallrye] (ServerService Thread Pool -- 58) WFLYHEALTH0001: Activating Eclipse MicroProfile Health Subsystem
15:29:35,886 INFO [org.wildfly.extension.microprofile.opentracing] (ServerService Thread Pool -- 59) WFLYTRACEXT0001: Activating MicroProfile OpenTracing Subsystem
15:29:35,885 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-2) WFLYJCA0010: Unbound data source [java:jboss/datasources/ExampleDS]
15:29:35,878 INFO [org.jboss.as.webservices] (ServerService Thread Pool -- 70) WFLYWS0002: Activating WebServices Extension
15:29:35,875 INFO [org.jboss.as.security] (ServerService Thread Pool -- 66) WFLYSEC0002: Activating Security Subsystem
15:29:36,145 INFO [org.wildfly.extension.undertow] (MSC service thread 1-6) WFLYUT0012: Started server default-server.
15:29:36,096 INFO [org.jboss.as.mail.extension] (MSC service thread 1-1) WFLYMAIL0001: Bound mail session [java:jboss/mail/Default]
15:29:36,080 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 69) WFLYUT0014: Creating file handler for path 'F:\Desktop\wildfly-14.0.0.Final/welcome-content' with options [directory-listing: 'false', follow-symlink: 'false', case-sensitive: 'true', safe-symlink-paths: '[]']
15:29:36,066 INFO [org.jboss.as.ejb3] (MSC service thread 1-8) WFLYEJB0481: Strict pool slsb-strict-max-pool is using a max instance size of 64 (per class), which is derived from thread worker pool sizing.
15:29:36,062 INFO [org.jboss.as.ejb3] (MSC service thread 1-5) WFLYEJB0482: Strict pool mdb-strict-max-pool is using a max instance size of 16 (per class), which is derived from the number of CPUs on this host.
15:29:36,166 INFO [org.wildfly.extension.undertow] (MSC service thread 1-2) WFLYUT0018: Host default-host starting
15:29:36,164 INFO [org.jboss.as.security] (MSC service thread 1-1) WFLYSEC0001: Current PicketBox version=5.0.3.Final
15:29:36,596 INFO [org.jboss.as.patching] (MSC service thread 1-5) WFLYPAT0050: WildFly Full cumulative patch ID is: base, one-off patches include: none
15:29:36,609 WARN [org.jboss.as.domain.management.security] (MSC service thread 1-5) WFLYDM0111: Keystore F:\Desktop\wildfly-14.0.0.Final\standalone\configuration\application.keystore not found, it will be auto generated on first use with a self signed certificate for host localhost
15:29:36,616 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-4) WFLYDS0013: Started FileSystemDeploymentService for directory F:\Desktop\wildfly-14.0.0.Final\standalone\deployments
15:29:36,989 INFO [org.wildfly.extension.undertow] (MSC service thread 1-2) WFLYUT0006: Undertow HTTP listener default listening on 127.0.0.1:8080
15:29:37,059 INFO [org.jboss.as.ejb3] (MSC service thread 1-3) WFLYEJB0493: EJB subsystem suspension complete
15:29:37,120 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-4) WFLYJCA0001: Bound data source [java:jboss/datasources/ExampleDS]
15:29:37,285 INFO [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0006: Undertow HTTPS listener https listening on 127.0.0.1:8443
15:29:37,353 INFO [org.jboss.ws.common.management] (MSC service thread 1-6) JBWS022052: Starting JBossWS 5.2.3.Final (Apache CXF 3.2.5.jbossorg-1)
15:29:37,405 INFO [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0212: Resuming server
15:29:37,407 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
15:29:37,407 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
15:29:37,408 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 14.0.0.Final (WildFly Core 6.0.1.Final) started in 4668ms - Started 306 of 527 services (321 services are lazy, passive or on-demand)
通过以上部分日志可以看到,wildfly监听了8080,8443和9990端口。
访问项目的url为:127.0.0.1:8080,访问管理后台的url为:http://127.0.0.1:9990/或http://localhost:9990。访问服务器可看到如下界面:
在该页面中我们可以看到我的wildfly没有添加用户,这里也给出了添加用户的方法,点击bin目录下的add-user.bat文件即可。
What type of user do you wish to add?a) Management User (mgmt-users.properties)b) Application User (application-users.properties)
# 输入a,以添加管理员用户
(a): aEnter the details of the new user to add.
Using realm 'ManagementRealm' as discovered from the existing property files.
# 输入用户名
Username : test
Password recommendations are listed below. To modify these restrictions edit the add-user.properties configuration file.- The password should be different from the username- The password should not be one of the following restricted values {root, admin, administrator}- The password should contain at least 8 characters, 1 alphabetic character(s), 1 digit(s), 1 non-alphanumeric symbol(s)
# 输入用户密码
Password :
WFLYDM0098: The password should be different from the username
Are you sure you want to use the password entered yes/no? yes
# 确认密码
Re-enter Password :
What groups do you want this user to belong to? (Please enter a comma separated list, or leave blank for none)[ ]: yes
About to add user 'test' for realm 'ManagementRealm'
# 继续则输入yes
Is this correct yes/no? yes
Added user 'test' to file 'F:\Desktop\wildfly-14.0.0.Final\standalone\configuration\mgmt-users.properties'
Added user 'test' to file 'F:\Desktop\wildfly-14.0.0.Final\domain\configuration\mgmt-users.properties'
Added user 'test' with groups yes to file 'F:\Desktop\wildfly-14.0.0.Final\standalone\configuration\mgmt-groups.properties'
Added user 'test' with groups yes to file 'F:\Desktop\wildfly-14.0.0.Final\domain\configuration\mgmt-groups.properties'
Is this new user going to be used for one AS process to connect to another AS process?
e.g. for a slave host controller connecting to the master or for a Remoting connection for server to server EJB calls.
# 继续则输入yes
yes/no? yes
# 这里需要注意,用户添加完毕后,将回馈给你此用户的secret value,可在domain与slave 的通信中用到
To represent the user add the following to the server-identities definition <secret value="dGVzdA==" />
每一步操作都会有对应的提示与选项,按照提示填写即可。
设置完成,刷新页面,输入刚刚设置的用户名密码,即可登录管理后台,登录成功后就可以操作后台部署项目了。
三、项目快速部署
进入项目后台管理界面,点击导航栏上的Deployments或首页Deployments下的start,打开项目部署页面。
点击Deployment旁边的+号,选择第一项,Upload Deployment上传部署。点击Choose a file or drag it here在本机上选择项目的war包,点击下一步。
设置项目名称,这里的两个名称最好是一样的,这样可以省去很多麻烦(详细信息参考左上角 ?help),打开Enable,点击Finish,当显示Upload successful时,表示项目已经部署成功了。
在浏览器输入http://localhost:8080/项目名或点击页面上的 Context Root
如果要使用IP地址访问项目,则需要修改standalone/configuration目录下的standalone.xml文件,拉到最下面,将interfaces标签里的127.0.0.1改成你的IP地址即可。