在没有Artifactory的情况下部署到weblogic

时间:2015-12-17 20:51:57

标签: weblogic artifactory

有没有办法通过maven将war文件部署到Weblogic而不向Artifactory发送版本?

这是我的pom.xml文件:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>...</groupId>
    <artifactId>...</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>... Maven Webapp</name>
      <repositories>
        <repository>
            <id>...</id>
            <name>...</name>
            <url>...</url>
        </repository>
    </repositories>
    <build>
        <finalName>${project.artifactId}</finalName>
        <sourceDirectory>${project.basedir}/src</sourceDirectory>
        <outputDirectory>${project.basedir}/target/classes</outputDirectory>
        <resources>
            <resource>
                <targetPath>content</targetPath>
                <directory>WEB-INF</directory>
                <includes>
                    <include>Language-ext.properties</include>
                </includes>
            </resource>
        </resources>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.0.2</version>
                    <configuration>
                        <source>1.5</source>
                        <target>1.5</target>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.1.1</version>
                    <configuration>
                        <webXml>${project.basedir}/src/main/webapp/WEB-INF/web.xml</webXml>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>com.oracle.weblogic</groupId>
                    <artifactId>weblogic-maven-plugin</artifactId>
                    <version>10.3.4</version>
                    <configuration>
                        <adminurl>${wls.admin.url}</adminurl>
                        <user>${wls.admin.username}</user>
                        <password>${wls.admin.password}</password>
                        <upload>true</upload>
                        <stage>true</stage>
                        <action>deploy</action>
                        <verbose>true</verbose>
                        <source>${project.build.directory}/${project.build.finalName}.${project.packaging}</source>
                        <name>${project.build.finalName}</name>
                        <targets>${deploy.targets}</targets>
                        <usenonexclusivelock>true</usenonexclusivelock>
                        <artifactLocation>
                           C:\temp\portlet.war
                        </artifactLocation>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
    <dependencies>
        <dependency>
            <groupId>javax.portlet</groupId>
            <artifactId>portlet-api</artifactId>
            <version>2.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.1.1</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.14</version>
        </dependency>
        <dependency>
            <groupId>taglibs</groupId>
            <artifactId>standard</artifactId>
            <version>1.1.2</version>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.1.1</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-asm</artifactId>
            <version>3.0.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>3.0.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>3.0.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>3.0.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-expression</artifactId>
            <version>3.0.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc-portlet</artifactId>
            <version>3.0.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>3.0.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>3.0.2.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-core-asl</artifactId>
            <version>1.9.5</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>1.9.5</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.3</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.annotation</groupId>
            <artifactId>jsr250-api</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.axis</groupId>
            <artifactId>axis</artifactId>
            <version>1.4</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>...</groupId>
            <artifactId>...</artifactId>
            <version>2.0.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
          <groupId>...</groupId>
          <artifactId>...</artifactId>
          <version>8.2</version>
        </dependency>
        <dependency>
            <groupId>...</groupId>
            <artifactId>...</artifactId>
            <version>10.0.51</version>
            <scope>provided</scope>
        </dependency>
        <dependency>        
            <groupId>br.com.gvt.portlets</groupId>
            <artifactId>BasePortlet</artifactId>
            <version>2.0.0</version>            
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <id>wl-local</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <properties>
                <wls.admin.url>t3://...</wls.admin.url>
                <wls.admin.username>...</wls.admin.username>
                <wls.admin.password>...</wls.admin.password>
                <deploy.remote>true</deploy.remote>
                <deploy.targets>...</deploy.targets>
            </properties>

            <pluginRepositories>
                <pluginRepository>
                    <id>...</id>
                    <name>...</name>
                    <url>...</url>
                </pluginRepository>
            </pluginRepositories>

        </profile>

        <profile>
            <id>wl-remote</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>

            <properties>
                <wls.admin.url>${adminurl}</wls.admin.url>
                <wls.admin.username>${user}</wls.admin.username>
                <wls.admin.password>${password}</wls.admin.password>
                <deploy.remote>true</deploy.remote>
                <deploy.targets>${targets}</deploy.targets>
            </properties>
        </profile>
    </profiles>
    <distributionManagement>
        <repository>
            <uniqueVersion>false</uniqueVersion>
            <id>corp1</id>
            <name>Corporate Repository</name>
            <url>file:C:/temp/</url>
            <layout>default</layout>
        </repository>
    </distributionManagement>
</project>

使用mvn deploy时使用此配置可​​以在C:\ temp

中保存大量文件,包括war文件

2 个答案:

答案 0 :(得分:0)

使用WebLogic Development Maven插件。 wls-maven-plugin&#34;提供增强的功能来安装,启动和停止服务器,创建域,执行WLST脚本,以及编译和部署应用程序&#34;。

https://docs.oracle.com/cd/E24329_01/web.1211/e24368/maven.htm#WLPRG591

答案 1 :(得分:0)

我们已经解决了这个问题,我可以使用eclipse Run作为maven build部署到weblogic ...

在Goals属性中我放了:

wls:undeploy -DmiddlewareHome = C:\ Oracle \ Middleware \ Oracle_Home -DweblogicHome = C:\ Oracle \ Middleware \ Oracle_Home \ wlserver -Dadminurl = t3:// host:7000 -Duser = user -Dpassword = password -Dtargets = targets -Dname = nameofproject -Dremote = false -Dupload = true wls:redeploy -DmiddlewareHome = C:\ Oracle \ Middleware \ Oracle_Home -DweblogicHome = C:\ Oracle \ Middleware \ Oracle_Home \ wlserver -Dadminurl = t3:// host: 7000 -Duser = user -Dpassword = password -Dtargets = targets -Dname = nameofproject -Dremote = false -Dupload = true

并在“用户设置”字段中使用settings.xml文件,如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <profiles>
    <profile>
      <repositories>
        <repository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>libs-releases</name>
          <url>http://host:8081/artifactory/libs-releases</url>
        </repository>
        <repository>
          <snapshots />
          <id>snapshots</id>
          <name>libs-snapshots</name>
          <url>http://host:8081/artifactory/libs-snapshots</url>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>plugins-releases</name>
          <url>http://host:8081/artifactory/plugins-releases</url>
        </pluginRepository>
        <pluginRepository>
          <snapshots />
          <id>snapshots</id>
          <name>plugins-snapshots</name>
          <url>http://host:8081/artifactory/plugins-snapshots</url>
        </pluginRepository>
      </pluginRepositories>
      <id>artifactory</id>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>artifactory</activeProfile>
  </activeProfiles>

  <pluginGroups>
     <pluginGroup>com.oracle.weblogic</pluginGroup>
 </pluginGroups> 
</settings>

它需要花费一些时间来取消部署和部署war文件,但它比手动更好。

谢谢大家。