我们有两个pom.xml文件,一个是父pom,另一个是子pom。在父pom中,我定义了所有依赖关系。 pom文件是:
父pom
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>OSB-Project</groupId>
<artifactId>OSB-shiv</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>deafult-cli</id>
<phase>package</phase>
<configuration>
<properties name="basedir" value="."/>
<target>
<taskdef name="configjar"
classname="com.bea.alsb.tools.configjar.ant.ConfigJarTask"
classpathref="maven.plugin.classpath"/>
<configjar settingsFile="../common/settings.xml"
debug="true">
</configjar>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.7.1</version>
<scope>system</scope>
<systemPath>C:/Users/52014918/shiv/workspace/common/lib/ant.jar</systemPath>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-launcher</artifactId>
<version>1.7.1</version>
<scope>system</scope>
<systemPath>C:/Users/52014918/shiv/workspace/common/lib/ant-launcher.jar</systemPath>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-nodeps</artifactId>
<version>1.7.1</version>
<scope>system</scope>
<systemPath>C:/Users/52014918/shiv/workspace/common/lib/ant-nodeps.jar</systemPath>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-apache-bsf</artifactId>
<version>1.7.1</version>
<scope>system</scope>
<systemPath>C:/Users/52014918/shiv/workspace/common/lib/ant-apache-bsf.jar</systemPath>
</dependency>
<dependency>
<groupId>com.oracle.osb</groupId>
<artifactId>configjar</artifactId>
<version>11.1.1.7</version>
<scope>system</scope>
<systemPath>C:/Users/52014918/shiv/workspace/common/lib/configjar.jar</systemPath>
</dependency>
<dependency>
<groupId>com.oracle.osb</groupId>
<artifactId>weblogic.server.modules_10.3.6.0</artifactId>
<version>11.1.1.7</version>
<scope>system</scope>
<systemPath>C:/Users/52014918/shiv/workspace/common/lib/weblogic.server.modules_10.3.6.0.jar</systemPath>
</dependency>
<dependency>
<groupId>com.oracle.osb</groupId>
<artifactId>weblogic</artifactId>
<version>11.1.1.7</version>
<scope>system</scope>
<systemPath>C:/Users/52014918/shiv/workspace/common/lib/weblogic.jar</systemPath>
</dependency>
<dependency>
<groupId>com.oracle.osb</groupId>
<artifactId>oracle.http_client_11.1.1</artifactId>
<version>11.1.1.7</version>
<scope>system</scope>
<systemPath>C:/Users/52014918/shiv/workspace/common/lib/oracle.http_client_11.1.1.jar</systemPath>
</dependency>
<dependency>
<groupId>com.oracle.osb</groupId>
<artifactId>xmlparserv2</artifactId>
<version>11.1.1.7</version>
<scope>system</scope>
<systemPath>C:/Users/52014918/shiv/workspace/common/lib/xmlparserv2.jar</systemPath>
</dependency>
<dependency>
<groupId>com.oracle.osb</groupId>
<artifactId>orawsdl</artifactId>
<version>11.1.1.7</version>
<scope>system</scope>
<systemPath>C:/Users/52014918/shiv/workspace/common/lib/orawsdl.jar</systemPath>
</dependency>
<dependency>
<groupId>com.oracle.osb</groupId>
<artifactId>wsm-dependencies</artifactId>
<version>11.1.1.7</version>
<scope>system</scope>
<systemPath>C:/Users/52014918/shiv/workspace/common/lib/wsm-dependencies.jar</systemPath>
</dependency>
<dependency>
<groupId>com.oracle.osb</groupId>
<artifactId>osb.server.modules_11.1.1.7</artifactId>
<version>11.1.1.7</version>
<scope>system</scope>
<systemPath>C:/Users/52014918/shiv/workspace/common/lib/osb.server.modules_11.1.1.7.jar</systemPath>
</dependency>
<dependency>
<groupId>com.oracle.osb</groupId>
<artifactId>oracle.soa.common.adapters</artifactId>
<version>11.1.1.7</version>
<scope>system</scope>
<systemPath>C:/Users/52014918/shiv/workspace/common/lib/oracle.soa.common.adapters.jar</systemPath>
</dependency>
<dependency>
<groupId>com.oracle.osb</groupId>
<artifactId>log4j_1.2.8</artifactId>
<version>11.1.1.7</version>
<scope>system</scope>
<systemPath>C:/Users/52014918/shiv/workspace/common/lib/log4j_1.2.8.jar</systemPath>
</dependency>
<dependency>
<groupId>com.oracle.osb</groupId>
<artifactId>alsb</artifactId>
<version>11.1.1.7</version>
<scope>system</scope>
<systemPath>C:/Users/52014918/shiv/workspace/common/lib/alsb.jar</systemPath>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>../common/properties/environment.${env}</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>dev</id>
<properties>
<env>environment.dev</env>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>Using environment.dev.properties</echo>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>qa</id>
<properties>
<env>environment.qa</env>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>Using environment.qa.properties</echo>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>prod</id>
<properties>
<env>environment.prod</env>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>Using environment.prod.properties</echo>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
儿童pom
<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/xsd/maven-4.0.0.xsd">
<parent>
<groupId>OSB-Project</groupId>
<artifactId>OSB-shiv</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../common/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>clicktotalk</groupId>
<artifactId>clicktotalk-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<build>
<filters>
<filter>../common/properties/environment.${env}</filter>
</filters>
<defaultGoal>install</defaultGoal>
<resources>
<resource>
<directory>../common/properties</directory>
<filtering>true</filtering>
<includes>
<include>*.properties</include>
</includes>
</resource>
</resources>
</build>
</project>
在命令提示符下的类路径中设置Fer jar:
SET CLASSPATH=C:/Users/52014918/shiv/workspace/common/lib/sb-kernel-api.jar;C:/Users/52014918/shiv/workspace/common/lib/sb-kernel-impl.jar;C:/Users/52014918/shiv/workspace/common/lib/com.bea.common.configfwk_1.7.0.0.jar;
未创建Jar,出现错误:
C:\Users\52014918\shiv\workspace\clicktotalk1>mvn -Denv=dev
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building clicktotalk-service 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- properties-maven-plugin:1.0-alpha-2:read-project-properties (default) @ clicktotalk-service ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ clicktotalk-service ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ clicktotalk-service ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ clicktotalk-service ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\52014918\shiv`enter code here`\workspace\clicktotalk1\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ clicktotalk-service ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ clicktotalk-service ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ clicktotalk-service ---
[INFO]
[INFO] --- maven-antrun-plugin:1.7:run (deafult-cli) @ clicktotalk-service ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.757 s
[INFO] Finished at: 2018-06-29T13:10:03+05:30
[INFO] Final Memory: 11M/148M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.7:run (deafult-cli) on project clicktotalk-service: Error executing ant tasks: weblogic/utils/NestedException: weblogic.utils.NestedException-> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException