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

Deploy to weblogic without 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 文件

使用 WebLogic Development Maven 插件。 wls-maven-plugin "provides enhanced functionality to install, start and stop servers, create domains, execute WLST scripts, and compile and deploy applications".

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

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

我在目标属性上输入:

wls:undeploy -DmiddlewareHome=C:\Oracle\Middleware\Oracle_Home -DweblogicHome=C:\Oracle\Middleware\Oracle_Home\wlserver -Dadminurl=t3://host:7000 -Duser=user -Dpassword=密码 -Dtargets=目标 -Dname=项目名称 -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 文件需要一些时间,但比手动执行要好。

谢谢大家