在weblogic中部署項目通常有三種方式:第一,在控制台中安裝部署;第二,將部署包放在domain域中autodeploy目錄下部署;第三,使用域中配置文件config.xml 進行項目的部署。
控制台部署
1 啟動weblogic服務,登錄到weblogic控制台頁面,輸入用戶名和密碼,登錄到控制台里面
2 點擊左側的部署
3 在右側點擊安裝按鈕,准備進行項目安裝
如果安裝是灰色的按鈕不能點擊,這時候點擊左上角的“鎖定並編輯按鈕“
4 看到路徑輸入框,可以在下面選擇要部署的項目的位置
5 也可以直接輸入要部署的包的位置,敲回車
6 點擊下一步即可
7 繼續下一步
8 點擊完成按鈕
9 保存前面各步的設置
10 保存完成后,會看到激活更改的提示,且不需要重啟。
11 這時便可以進行測試了,輸入項目名稱,看到了項目的歡迎頁面,即項目部署成功。
如果前面的步驟操作完成了,但依然無法訪問項目的話,可以參考下面的補充步驟
補充步驟
補1 點擊部署,勾選上項目,點擊啟動
補2 待啟動后,項目狀態為活動,健康狀況為OK時,繼續測試。
autodeploy自動部署
自動部署時不需要登錄控制台,在domain域的主目錄下面有個autodeploy目錄,直接將項目包拷貝到autodeploy目錄下面就可以了。
autodeploy目錄里面有個readme.txt 文檔,打開看一下,這里摘第一段出來
- This autodeploy directory provides a quick way to deploy applications
- to a development server. When the WebLogic Server instance is running
- in development mode, applications and modules in this directory are
- automatically deployed.
主要說什么呢,就是開發模式下面,當weblogic啟動時,會自動部署autodeploy目錄下面的項目。
將部署包servletDemo.war 丟到autodeploy目錄下面,啟動startWeblogic.cmd ,進行servletDemo的訪問,依然可以看到
歡迎頁面。
config.xml配置文件部署
config.xml文件在domain域的config目錄下面,config.xml主要配置了domain域的一些相關信息
我們要部署項目,該在哪里配置呢
- <?xml version='1.0' encoding='UTF-8'?>
- <domain xmlns="http://xmlns.oracle.com/weblogic/domain" xmlns:sec="http://xmlns.oracle.com/weblogic/security" xmlns:wls="http://xmlns.oracle.com/weblogic/security/wls" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/weblogic/security/xacml http://xmlns.oracle.com/weblogic/security/xacml/1.0/xacml.xsd http://xmlns.oracle.com/weblogic/security/providers/passwordvalidator http://xmlns.oracle.com/weblogic/security/providers/passwordvalidator/1.0/passwordvalidator.xsd http://xmlns.oracle.com/weblogic/domain http://xmlns.oracle.com/weblogic/1.0/domain.xsd http://xmlns.oracle.com/weblogic/security http://xmlns.oracle.com/weblogic/1.0/security.xsd http://xmlns.oracle.com/weblogic/security/wls http://xmlns.oracle.com/weblogic/security/wls/1.0/wls.xsd">
- <name>base_domain</name>
- <domain-version>12.1.3.0.0</domain-version>
- <security-configuration>
- <name>base_domain</name>
- <realm>
- <sec:authentication-provider xsi:type="wls:default-authenticatorType">
- <sec:name>DefaultAuthenticator</sec:name>
- </sec:authentication-provider>
- <sec:password-validator xmlns:pas="http://xmlns.oracle.com/weblogic/security/providers/passwordvalidator" xsi:type="pas:system-password-validatorType">
- <sec:name>SystemPasswordValidator</sec:name>
- <pas:min-password-length>8</pas:min-password-length>
- <pas:min-numeric-or-special-characters>1</pas:min-numeric-or-special-characters>
- </sec:password-validator>
- </realm>
- <default-realm>myrealm</default-realm>
- <credential-encrypted>{AES}xLPXh4gcT6JErTB+toxRZ1pQpAS+MGMuqnnXzu/OsxWMQTB8152ggdbUlhkSXUGC9f959oL7tIzyZiu9XdeajlkK9vAu9cQlCKLLUaUMyl5Ty4C0uuJA99b14eR7oIu4</credential-encrypted>
- <node-manager-username>weblogic</node-manager-username>
- <node-manager-password-encrypted>{AES}n3LLdgmAsocPRoYUrFfR2waWOlEz6KDFsp7+gByNeo8=</node-manager-password-encrypted>
- </security-configuration>
- <server>
- <name>AdminServer</name>
- <listen-address></listen-address>
- </server>
- <embedded-ldap>
- <name>base_domain</name>
- <credential-encrypted>{AES}21z8vCiCbuaYqsSj5t5+y6qvEY8dE3NdNr0zDG+K3EdwWEubzk9Vmx79Di43oxqX</credential-encrypted>
- </embedded-ldap>
- <configuration-version>12.1.3.0.0</configuration-version>
- <admin-server-name>AdminServer</admin-server-name>
- </domain>
我們的項目部署信息添加在configuration-version 和 admin-server-name 之間
- <configuration-version>12.1.3.0.0</configuration-version>
- <app-deployment>
- <name>servletDemo</name>
- <target>AdminServer</target>
- <module-type>war</module-type>
- <source-path>C:\Users\ZhangQi\Desktop\servletDemo</source-path>
- <security-dd-model>DDOnly</security-dd-model>
- </app-deployment>
- <admin-server-name>AdminServer</admin-server-name>
剛開始進行config.xml 配置文件部署的時候,出現了404,修改了下配置就可以了
將部署的war包解壓為文件夾的形式,然后
將 <module-type>war</module-type> 里面的war 修改為 dir 即可
- <app-deployment>
- <name>servletDemo</name>
- <target>AdminServer</target>
- <module-type>dir</module-type>
- <source-path>C:\Users\ZhangQi\Desktop\servletDemo</source-path>
- <security-dd-model>DDOnly</security-dd-model>
- <staging-mode>nostage</staging-mode>
- </app-deployment>
然后啟動weblogic服務即可。