温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

使用m2Eclipse 通过 maven 自动部署webapp到weblogic 12c

发布时间:2020-04-07 13:29:33 来源:网络 阅读:3439 作者:vjjy001 栏目:关系型数据库

这是oracle 官网介绍通过maven weblogic plug-in 来自动部署war 包 到weblogic 12c/11R

这是官方详细介绍如何使用maven 部署到weblogic12c http://docs.oracle.com/cd/E24329_01/web.1211/e24368/maven.htm#WLPRG585

 本人结合实际操作来说明如何通过m2eclipse(maven)+ eclipse自动部署到weblogic 服务器

 

第一部分: 设置eclipse

 

1 确保eclipse 已经安装了m2eclipse

通过点击file-new -maven project

如果成功显示并能创建项目,则表示maven eclipse 插件已经安装了

使用m2Eclipse 通过 maven 自动部署webapp到weblogic 12c r

 

2 创建一个maven web app project

使用m2Eclipse 通过 maven 自动部署webapp到weblogic 12c

 

3 创建成功后的maven 项目结构

使用m2Eclipse 通过 maven 自动部署webapp到weblogic 12c

 

 

4 右键点击pom.xml 文件 - run as maven- install

 

 

第二部分: 配置maven weblogic plugin (weblogic 插件)(难点)

 

weblogic 可以被maven自动部署的前提是在weblogic 下已经有这两个文件

MW_HOME/wlserver_12.1/server/lib/wls-maven-plugin.jar

MW_HOME/wlserver_12.1/server/lib/pom.xml

 

下面展示如何配置从而是weblogic 下包含这两个文件

1 定位到C:/wls12120/wlserver/server/lib

 

2 在C:/wls12120/wlserver/server/lib目录下运行

mvn install
mvn install -Dfile=wls-maven-plugin.jar -DpomFile=pom.xml
 
/*复制pom.xml 和wls-maven-plugin.jar 到以下//depo/.m2/repository/com/oracle/weblogic/wls-maven-plugin 目录 
*/
//执行  
  mvn install:install-file -Dfile=wls-maven-plugin.jar -DpomFile=pom.xml

如果成功执行会显示build success 并且此时lib 目录下面多了wls-maven-plugin.jarpom.xml

验证是否成功

  C:\wls12120\wlserver\server\lib>mvn wls:help
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------------------------------------------------------
[INFO] Building WebLogic Server Maven Plugin 12.1.2.0
[INFO] -----------------------------------------------------------------------
[INFO]
[INFO] --- wls-maven-plugin:12.1.2.0:help (default-cli) @ wls-maven-plugin ---
[INFO]
WebLogic Server Maven Plugin
The following goals are supported by wls-maven-plugin:
appc:
  Generates and compiles the classes needed to deploy EJBs and JSPs to
  WebLogic Server. Also validates the deployment descriptors for compliance
  with the current specifications at both the individual module level and
  the application level.
deploy:
  Deploys WebLogic Server applications and modules. Supports all deployment
  formats, such as WAR, JAR, etc.
create-domain:
  Create a domain for WebLogic Server using the default domain template.
  For more complex domain creation use the WLST goal.

 

 

 

第三部分: 整合eclipse 和 自动部署

上述两部分完成后, 可以开始整合eclipse

1 配置eclipse 项目下的porm.xml

修改eclipse 项目下空白的porm.xml,添加<build>信息代码如下

<build>
    <finalName>MavenWebStruts</finalName>
 
    <plugins>
 
     <plugin>
        <artifactId>maven-plugin-plugin</artifactId>
        <version>2.3</version>
        <configuration>
          <goalPrefix>wls</goalPrefix>
        </configuration>
      </plugin>
 
 
 
    <plugin>
 
	<groupId>org.apache.maven.plugins</groupId>
 
	<artifactId>maven-compiler-plugin</artifactId>
 
	<configuration>
 
	<source>1.7.0_13</source>
 
	<target>1.7.0_13</target>
 
	<debug>false</debug>
	
	<encoding>UTF-8</encoding>
	
	</configuration>
	
	</plugin>
	
	<plugin>
 
<groupId>org.apache.maven.plugins</groupId>
 
<artifactId>maven-war-plugin</artifactId>
 
<version>2.1.1</version>
 
<configuration>
 
<failOnMissingWebXml>false</failOnMissingWebXml>
 
</configuration>
 
</plugin>
 
 
 
<plugin>
 
<groupId>org.apache.maven.plugins</groupId>
 
<artifactId>maven-surefire-plugin</artifactId>
 
<version>2.11</version>
 
<configuration>
 
<skipTests>true</skipTests>
 
</configuration>
 
</plugin>
 
    <!-- WebLogic Server 12c Maven Plugin -->
            <plugin>
                <groupId>com.oracle.weblogic</groupId>
                <artifactId>wls-maven-plugin</artifactId>
                <version>12.1.2.0</version>
            <configuration>
 
	      <name>${project.build.finalName}</name>
 
		     <middlewareHome>C:\wls12120</middlewareHome>
			
			<user>账户</user>
			<adminurl>t3://localhost:7001</adminurl>
			<password>密码</password>
			<source>${project.build.directory}/${project.build.finalName}.${project.packaging}</source>
</configuration>
 
 
 
            </plugin>
 
 
    </plugins>
  </build>

重点是是在<build></build>下添加com.oracle.weblogic plugin.

补充以下一些标签含义

<user>weblogic账户

<password>weblogic 密码

<source>表示war/ear的位置

 

2 通过eclipse 部署项目

为了测试是否能成功部署先测试wls 插件是否生效

右键点击porm.xml 运行

使用m2Eclipse 通过 maven 自动部署webapp到weblogic 12c

[INFO] Building MavenWebStruts Maven Webapp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- wls-maven-plugin:12.1.2.0:help (default-cli) @ MavenWebStruts ---
[INFO]
WebLogic Server Maven Plugin
The following goals are supported by wls-maven-plugin:
 
appc:
Generates and compiles the classes needed to deploy EJBs and JSPs to
WebLogic Server. Also validates the deployment descriptors for compliance
with the current specifications at both the individual module level and
the application level.
 
deploy:
Deploys WebLogic Server applications and modules. Supports all deployment
formats, such as WAR, JAR, etc.
 
create-domain:
Create a domain for WebLogic Server using the default domain template.
For more complex domain creation use the WLST goal.
 
help:
Lists all the goals supported by the <code>wls-maven-plugin</code>.
 
install:
Installs WebLogic Server.
 
list-apps:
Lists the deployment names for applications and standalone modules
deployed, distributed, or installed in the domain.
 
redeploy:
Redeploys a running application or part of a running application.
 
start-app:
Starts an application deployed on WebLogic Server.
 
start-server:
Starts WebLogic Server.
 
stop-app:
Stops an application.
 
stop-server:
Stops WebLogic Server.
 
undeploy:
Undeploys the application from WebLogic Server. Stops the deployment unit
and removes staged files from target servers.
 
update-app:
Updates an application's deployment plan by redistributing the plan files
and reconfiguring the application based on the new plan contents.
 
wlst:
WLST wrapper for Maven.
 
ws-clientgen:
A Maven goal to generate client web service artifacts from a WSDL
 
ws-wsdlc:
A Maven goal to generate a set of artifacts and a partial Java
implementation of the Web service from a WSDL.
 
ws-jwsc:
A Maven goal to build a JAX-WS web service
 
 
For detailed help on a goal, use -Dgoal=<goal-name> -Ddetail=true options.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.796 s
[INFO] Finished at: 2015-08-27T15:50:03-05:00
[INFO] Final Memory: 6M/112M
[INFO] ------------------------------------------------------------------------

如果出现以上信息说明整合成功

 

最后启动服务器,并且运行以下命令.

使用m2Eclipse 通过 maven 自动部署webapp到weblogic 12c

 

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI