JBoss AS 從8版本起名爲wildfly。Wildfly是一個開源的基於JavaEE的輕量級應用服務器。能夠在任何商業應用中無償使用。java
WildFly是一個靈活的、輕量的、強大管理能力的應用程序服務器。Wildfly是一個管理EJB的容器和服務器,但JBoss核心服務不包括支持servlet/JSP的WEB容器,通常與Tomcat或Jetty綁定使用。git
Wildfly更多特色及與市面上常見的Web服務對比,可參看《熱門WEB容器TOMCAT、JETTY、 GLASSFISH、WILDFLY對比》。web
wildfly下載地址:https://wildfly.org/downloads/tomcat
目前,最新版本是18.0.0.Final,選擇「Java EE Full & Web Distribution」項對應的ZIP版本,點擊下載便可。若是官網下載較慢,可關注微信公衆號「程序新視界」,回覆「wildfly」得到下載連接。服務器
安裝java環境要求Java8或更高版本。微信
所謂的安裝即解壓便可。下面看一下該版本的目錄結構:網絡
├── LICENSE.txt ├── README.txt ├── appclient ├── bin ├── copyright.txt ├── docs ├── domain ├── jboss-modules.jar ├── modules ├── standalone └── welcome-content
standalone目錄下存放的應用將單獨佔用進程,可單獨啓動和關閉,之間沒有關聯性。旗下有許多xml文件可供啓動時選擇。app
domain目錄下的應用之間有關聯性,managing multiple servers from a single control point。dom
modules目錄,jboss採用module加載驅動。ide
重點看一下readme中的內容,提供了啓動相關的指導。
關鍵特性:
Key Features ------------ * Jakarta EE 8 support * Fast Startup * Small Footprint * Modular Design * Unified Configuration and Management * Distributed Domain Management
文檔獲取,同時也能夠看出啓動時默認是監聽8080端口。
Also, once WildFly is started you can go to http://localhost:8080/ for additional information.
啓動命令:
Starting a Standalone Server ---------------------------- A WildFly standalone server runs a single instance. <JBOSS_HOME>/bin/standalone.sh (Unix / Linux) <JBOSS_HOME>\bin\standalone.bat (Windows)
啓動腳本位於根目錄/bin目錄中。Windows爲standalone.bat,Linux爲standalone.sh。
Wildfly還能夠啓動一個管理後臺來對服務進行管理。
Starting a Managed Domain ------------------------- A WildFly managed domain allows you to control and configure multiple instances, potentially across several physical (or virtual) machines. The default configuration includes a domain controller and a single server group with three servers (two of which start automatically), all running on the localhost. <JBOSS_HOME>/bin/domain.sh (Unix / Linux) <JBOSS_HOME>\bin\domain.bat (Windows)
啓動腳本位於根目錄/bin目錄中。Windows爲domain.bat,Linux爲domain.sh。
中止服務,能夠經過控制檯輸入Ctrl+c命令來操做。若是服務在後臺運行,可執行一下命令進行中止。
<JBOSS_HOME>/bin/jboss-cli.sh --connect --command=:shutdown (Unix / Linux) <JBOSS_HOME>\bin\jboss-cli.bat --connect --command=:shutdown (Windows)
如今啓動項目standalone看一下效果。
19:48:11,234 INFO [org.jboss.as.ejb3] (MSC service thread 1-6) WFLYEJB0482: Strict pool mdb-strict-max-pool is using a max instance size of 32 (per class), which is derived from the number of CPUs on this host. 19:48:11,234 INFO [org.jboss.as.ejb3] (MSC service thread 1-2) WFLYEJB0481: Strict pool slsb-strict-max-pool is using a max instance size of 128 (per class), which is derived from thread worker pool sizing. 19:48:11,296 INFO [org.wildfly.extension.undertow] (MSC service thread 1-4) WFLYUT0006: Undertow HTTP listener default listening on 127.0.0.1:8080 19:48:11,409 INFO [org.jboss.as.ejb3] (MSC service thread 1-6) WFLYEJB0493: EJB subsystem suspension complete 19:48:11,479 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-3) WFLYJCA0001: Bound data source [java:jboss/datasources/ExampleDS] 19:48:11,579 INFO [org.jboss.as.patching] (MSC service thread 1-3) WFLYPAT0050: WildFly Full cumulative patch ID is: base, one-off patches include: none 19:48:11,596 WARN [org.jboss.as.domain.management.security] (MSC service thread 1-5) WFLYDM0111: Keystore /Users/zzs/tools/wildfly18/standalone/configuration/application.keystore not found, it will be auto generated on first use with a self signed certificate for host localhost 19:48:11,606 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-6) WFLYDS0013: Started FileSystemDeploymentService for directory /Users/zzs/tools/wildfly18/standalone/deployments 19:48:11,746 INFO [org.wildfly.extension.undertow] (MSC service thread 1-2) WFLYUT0006: Undertow HTTPS listener https listening on 127.0.0.1:8443 19:48:11,846 INFO [org.jboss.ws.common.management] (MSC service thread 1-2) JBWS022052: Starting JBossWS 5.3.0.Final (Apache CXF 3.3.3) 19:48:11,963 INFO [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0212: Resuming server 19:48:11,965 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management 19:48:11,965 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990 19:48:11,965 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 18.0.0.Final (WildFly Core 10.0.0.Final) started in 3880ms - Started 315 of 577 services (369 services are lazy, passive or on-demand)
經過以上部分日誌能夠看到,wildfly監聽了8080,8443和9990端口。
訪問服務器的url爲:127.0.0.1:8080,訪問管理後臺的url爲:http://127.0.0.1:9990/。
訪問服務器可看到以下頁面:
頁面內包含文檔、快速啓動、管理後臺等連接。
此時訪問後臺管理會提示以下內容:
Welcome to WildFly Your WildFly Application Server is running. However you have not yet added any users to be able to access the admin console. To add a new user execute the add-user.sh script within the bin folder of your WildFly installation and enter the requested information. By default the realm name used by WildFly is "ManagementRealm" this is already selected by default. After you have added the user follow this link to Try Again.
也就是說啓動成功了,但沒有配置用戶。同tomcat同樣,wildfly也有本身的服務管理頁面,能夠統一管理應用,設置權限用戶。執行add-user腳原本添加管理者用戶。
bin zzs$ ./add-user.sh What type of user do you wish to add? a) Management User (mgmt-users.properties) b) Application User (application-users.properties) # 輸入a,以添加管理用戶 (a): a Enter the details of the new user to add. Using realm 'ManagementRealm' as discovered from the existing property files. # 輸入用戶名 Username : zzs 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 : # 從新輸入密碼 Re-enter Password : # 留空便可或輸入ManagementRealm What groups do you want this user to belong to? (Please enter a comma separated list, or leave blank for none)[ ]: ManagementRealm About to add user 'zzs' for realm 'ManagementRealm' # 繼續則輸入yes Is this correct yes/no? yes Added user 'zzs' to file '/Users/zzs/tools/wildfly18/standalone/configuration/mgmt-users.properties' Added user 'zzs' to file '/Users/zzs/tools/wildfly18/domain/configuration/mgmt-users.properties' Added user 'zzs' with groups ManagementRealm to file '/Users/zzs/tools/wildfly18/standalone/configuration/mgmt-groups.properties' Added user 'zzs' with groups ManagementRealm to file '/Users/zzs/tools/wildfly18/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="MTk4NzEwMjlfUXE=" />
每一步操做都會有對應的提示與選項,按照提示填寫便可。
設置完成,再進點擊Administration Console或訪問http://127.0.0.1:9990/,輸入剛剛設置的用戶名密碼,便可登陸管理後臺。
原文連接:《wildfly(JBoss AS)應用服務器快速入門》
參考文章:《熱門WEB容器TOMCAT、JETTY、 GLASSFISH、WILDFLY對比》
<center>程序新視界:精彩和成長都不容錯過</center>