- 浏览: 29346 次
- 性别:
- 来自: 深圳
-
文章分类
最新评论
I always use ant to build/package,this is my first time to use maven2.
It's a ear maven project,also it include some sub maven project,such as war,ejb,jar and so on,here are the sample:
<1>cpp's pom.xml
<2> cpp-common's pom.xml
<3>cpp-ejb's pom.xml
<4>cpp-josso's pom.xml
<5>cpp-ear's pom.xml
It's a ear maven project,also it include some sub maven project,such as war,ejb,jar and so on,here are the sample:
<1>cpp's pom.xml
<project> <modelVersion>4.0.0</modelVersion> <groupId>com.nxj</groupId> <artifactId>cpp</artifactId> <packaging>pom</packaging> <version>1.0</version> <name>cpp</name> <modules> <module>cpp-common</module> <module>cpp-ejb</module> <module>cpp-josso</module> <module>cpp-ear</module> </modules> <reporting> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <configuration> <configLocation>sun_checks.xml</configLocation> </configuration> </plugin> </plugins> </reporting> </project>
<2> cpp-common's 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"> <parent> <groupId>com.nxj</groupId> <artifactId>cpp</artifactId> <version>1.0</version> </parent> <modelVersion>4.0.0</modelVersion> <groupId>com.nxj</groupId> <artifactId>cpp-common</artifactId> <packaging>jar</packaging> <version>1.0</version> <name>cpp-common</name> <url>..\..\cpp-common\target\site</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.1</version> <scope>test</scope> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate</artifactId> <version>3.2.0.ga</version> <optional>true</optional> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.9</version> <optional>true</optional> </dependency> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging-api</artifactId> <version>1.0.4</version> <optional>true</optional> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-ejb-plugin</artifactId> <configuration> <ejbVersion>3.0</ejbVersion> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> </plugins> </build> <reporting> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <configuration> <configLocation>sun_checks.xml</configLocation> </configuration> </plugin> </plugins> </reporting> </project>
<3>cpp-ejb's 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"> <parent> <groupId>com.nxj</groupId> <artifactId>cpp</artifactId> <version>1.0</version> </parent> <modelVersion>4.0.0</modelVersion> <groupId>com.nxj</groupId> <artifactId>cpp-ejb</artifactId> <packaging>ejb</packaging> <version>1.0</version> <name>cpp-ejb</name> <url>..\..\cpp-ejb\target\site</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.1</version> <scope>test</scope> </dependency> <dependency> <groupId>com.nxj</groupId> <artifactId>cpp-common</artifactId> <version>1.0</version> <optional>true</optional> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate</artifactId> <version>3.2.0.ga</version> <optional>true</optional> </dependency> <dependency> <groupId>jboss</groupId> <artifactId>jboss-annotations-ejb3</artifactId> <version>4.2.0.GA</version> <optional>true</optional> </dependency> <dependency> <groupId>jboss</groupId> <artifactId>jboss-ejb-api</artifactId> <version>4.2.0.GA</version> <optional>true</optional> </dependency> <dependency> <groupId>jboss.jbossws</groupId> <artifactId>jboss-jaxws</artifactId> <version>2.0.1.GA</version> <optional>true</optional> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.9</version> <optional>true</optional> </dependency> <dependency> <groupId>dom4j</groupId> <artifactId>dom4j</artifactId> <version>1.6</version> <optional>true</optional> </dependency> <!-- <dependency> <groupId>jtds</groupId> <artifactId>jtds</artifactId> <version>1.2.1</version> <optional>true</optional> </dependency> --> <dependency> <groupId>com.nxj</groupId> <artifactId>jboss-j2ee</artifactId> <version>1.0</version> <optional>true</optional> </dependency> <!-- <dependency> <groupId>antlr</groupId> <artifactId>antlr</artifactId> <version>2.7.6</version> <optional>true</optional> </dependency> <dependency> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> <version>2.1.1</version> <optional>true</optional> </dependency> <dependency> <groupId>cglib</groupId> <artifactId>cglib</artifactId> <version>2.1_3</version> <optional>true</optional> </dependency>--> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging-api</artifactId> <version>1.0.4</version> <optional>true</optional> </dependency> </dependencies> <build> <sourceDirectory>src/main/java</sourceDirectory> <testSourceDirectory>src/test/java</testSourceDirectory> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-ejb-plugin</artifactId> <configuration> <ejbVersion>3.0</ejbVersion> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> </plugins> </build> <repositories> <repository> <id>maven-repo</id> <name>Maven repository</name> <url>http://repo1.maven.org/maven2/</url> </repository> <repository> <id>jboss-repo</id> <name>jboss repository</name> <url>http://repository.jboss.com/maven2</url> </repository> </repositories> <reporting> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <configuration> <configLocation>sun_checks.xml</configLocation> </configuration> </plugin> </plugins> </reporting> </project>
<4>cpp-josso's pom.xml
<project> <parent> <groupId>com.nxj</groupId> <artifactId>cpp</artifactId> <version>1.0</version> </parent> <modelVersion>4.0.0</modelVersion> <groupId>com.nxj</groupId> <artifactId>cpp-josso</artifactId> <packaging>war</packaging> <version>1.0</version> <name>cpp-josso</name> <url>..\..\cpp-josso\target\site</url> <dependencies> <dependency> <groupId>com.nxj</groupId> <artifactId>cpp-common</artifactId> <version>1.0</version> <optional>true</optional> </dependency> <dependency> <groupId>com.nxj</groupId> <artifactId>cpp-ejb</artifactId> <version>1.0</version> <optional>true</optional> </dependency> <dependency> <groupId>javax.activation</groupId> <artifactId>activation</artifactId> <version>1.1</version> <scope>compile</scope> </dependency> <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> <version>1.3</version> <scope>compile</scope> </dependency> <dependency> <groupId>axis</groupId> <artifactId>axis</artifactId> <version>1.4</version> <scope>compile</scope> </dependency> <dependency> <groupId>com.nxj</groupId> <artifactId>josso</artifactId> <version>1.5</version> <scope>compile</scope> </dependency> <dependency> <groupId>struts</groupId> <artifactId>struts</artifactId> <version>1.2.2</version> <scope>compile</scope> </dependency> <dependency> <groupId>commons-codec</groupId> <artifactId>commons-codec</artifactId> <version>1.2</version> <scope>compile</scope> </dependency> <dependency> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> <version>3.1</version> <scope>compile</scope> </dependency> <dependency> <groupId>commons-beanutils</groupId> <artifactId>commons-beanutils</artifactId> <version>1.4</version> <scope>compile</scope> </dependency> <dependency> <groupId>commons-digester</groupId> <artifactId>commons-digester</artifactId> <version>1.8</version> <scope>compile</scope> </dependency> <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>1.1</version> <scope>compile</scope> </dependency> <dependency> <groupId>commons-httpclient</groupId> <artifactId>commons-httpclient</artifactId> <version>2.0</version> <scope>compile</scope> </dependency> <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> <version>2.0</version> <scope>compile</scope> </dependency> <dependency> <groupId>commons-validator</groupId> <artifactId>commons-validator</artifactId> <version>1.3.0</version> <scope>compile</scope> </dependency> <dependency> <groupId>oro</groupId> <artifactId>oro</artifactId> <version>2.0.8</version> <scope>compile</scope> </dependency> <dependency> <groupId>struts</groupId> <artifactId>struts</artifactId> <version>1.2.2</version> <scope>compile</scope> </dependency> <dependency> <groupId>struts</groupId> <artifactId>struts-legacy</artifactId> <version>1.1</version> <scope>compile</scope> </dependency> <dependency> <groupId>javax.mail</groupId> <artifactId>mail</artifactId> <version>1.4</version> <scope>compile</scope> </dependency> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging-api</artifactId> <version>1.0.4</version> <scope>compile</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.4</version> <scope>provided</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> </plugins> </build> <reporting> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <configuration> <configLocation>sun_checks.xml</configLocation> </configuration> </plugin> </plugins> </reporting> </project>
<5>cpp-ear's pom.xml
<project> <parent> <groupId>com.nxj</groupId> <artifactId>cpp</artifactId> <version>1.0</version> </parent> <modelVersion>4.0.0</modelVersion> <groupId>com.nxj</groupId> <artifactId>cpp-ear</artifactId> <name>cpp-ear</name> <packaging>ear</packaging> <description>cpp ear</description> <url>..\..\cpp-ear\target\site</url> <dependencies> <dependency> <groupId>com.nxj</groupId> <artifactId>cpp-common</artifactId> <version>1.0</version> </dependency> <dependency> <groupId>com.nxj</groupId> <artifactId>cpp-ejb</artifactId> <version>1.0</version> <type>ejb</type> </dependency> <dependency> <groupId>com.nxj</groupId> <artifactId>cpp-josso</artifactId> <version>1.0</version> <type>war</type> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-ear-plugin</artifactId> <configuration> <!--defaultBundleDir>lib</defaultBundleDir--> <modules> <jarModule> <groupId>com.nxj</groupId> <artifactId>cpp-common</artifactId> <includeInApplicationXml> true </includeInApplicationXml> </jarModule> <ejbModule> <groupId>com.nxj</groupId> <artifactId>cpp-ejb</artifactId> </ejbModule> <webModule> <groupId>com.nxj</groupId> <artifactId>cpp-josso</artifactId> <contextRoot>/josso</contextRoot> </webModule> </modules> </configuration> </plugin> </plugins> </build> <reporting> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <configuration> <configLocation>sun_checks.xml</configLocation> </configuration> </plugin> </plugins> </reporting> </project>
相关推荐
其次,Maven2提供了一套标准化的构建生命周期(Build Lifecycle),包括清理(clean)、初始化(initialize)、编译(compile)、测试(test)、打包(package)、验证(verify)、集成测试(integration-test)、...
执行`mvn package`命令后,Maven会根据配置生成对应的包文件。如果想要同时生成多个包,可以在`pom.xml`中添加多个`<execution>`标签,每个标签对应一个不同的assembly描述符。 `.classpath`和`.project`文件是...
**2. Maven Assembly 插件配置** 使用Maven Assembly插件首先需要在项目的pom.xml文件中添加对应的配置。以下是一个基本的配置示例: ```xml <build> <artifactId>maven-assembly-plugin</artifactId> ...
标题 "maven pdf" 暗示我们正在讨论如何在 Maven 项目中生成 PDF 文档。Maven 是一个流行的 Java 项目管理工具,它通过插件系统帮助开发者自动化构建、测试和部署应用程序。在这个场景中,PDF 可能是项目的文档、...
在`pom.xml`文件中的`<build>`部分,添加以下代码来引入`exec-maven-plugin`: ```xml <build> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>3.0.0</...
在Maven的`pom.xml`文件中,我们可以通过添加`<build>`标签下的`<plugins>`标签来配置`maven-assembly-plugin`。下面是一个基本的配置示例: ```xml ... <build> ... <artifactId>maven-assembly-plugin</...
标题 "maven 3.5.0 Cannot assign configuration entry 'pluginArtifacts' with value '${pl" 描述了一个在使用 Maven 3.5.0 版本时遇到的问题,该问题涉及到配置项 'pluginArtifacts' 的赋值错误,错误信息显示尝试...
- **构建生命周期(Build lifecycle)**:定义了构建过程中的不同阶段。 - **插件(Plugin)**:为Maven提供额外的功能。 - **POM文件**:项目的核心配置文件,包含了项目的元数据和构建逻辑。 - **依赖管理**:Maven...
# build with maven mvn package # or build with docker docker run -it --rm -v " $PWD " :/usr/src/mymaven -v " $HOME /.m2:/root/.m2 " -w /usr/src/mymaven maven:3.6.3-jdk-11 mvn clean install # run ...
- Better Builds with Maven:一本免费电子书,提供更深入的Maven使用指南。 2. Maven与Ant的区别: - Maven采用声明式配置,避免了Ant中的复杂脚本编写。 - Maven提供了一种标准的构建生命周期,包括清理、编译...
2. **使用AspectJ编译器**:Maven可以通过ajc(AspectJ编译器)插件来编译带有切面的Java源代码。我们需要在pom.xml中配置AspectJ Maven插件。 ```xml <build> ... ... <groupId>org.codehaus.mojo</groupId...
We will then develop object-relational mapping with Hibernate 4, build and package the application with Maven, and then deploy it in WildFly 8.1, followed by a demonstration of the use of Facelets in...
我们可以使用JUnit和Mockito进行单元测试,同时Spring还提供了`@RunWith(SpringRunner.class)`和`@SpringBootTest`注解来进行集成测试。 至于文件`monitor`,这可能是监控或者日志相关的配置或代码,它可能涉及...
3. **同步Maven项目**: 配置完成后,点击`Sync Project with Maven POM.xml`,IDEA会根据`pom.xml`文件下载所有依赖。 4. **运行Maven目标**: 你可以在`Maven Projects`面板中看到项目的所有Maven目标,点击目标...
Maven有多个生命周期阶段,如`clean`、`compile`、`test`、`package`等,每个阶段都包含了若干个目标(goal)。`maven-assembly-plugin`主要用于创建自定义的归档文件,如JAR、WAR或ZIP,通常在`package`阶段运行。 ...
Make the Docker build process integrate with the Maven build process. If you bind the default phases, when you type mvn package, you get a Docker image. When you type mvn deploy, your image gets ...
2. **执行构建**:运行`mvn package`命令,这将创建一个不含依赖的JAR和一个包含所有依赖的`dependency`目录。 3. **运行JAR**:由于依赖被单独打包,你需要确保运行JAR时,所有依赖的JAR都在`dependency/`目录下。...
<phase>package</phase> <goal>single</goal> </goals> </execution> </executions> </plugin> </plugins> </build> ``` 1. **插件配置**: - `groupId` 和 `artifactId` 指定了插件的坐标。 - `version...
在搜索框中输入 `m2e` 或 `Maven Integration for Eclipse`。 3. 选择合适的条目并点击 `Install` 完成安装。 - **检查 Eclipse 是否已安装 M2Eclipse Maven 支持** 查看 Eclipse 的偏好设置 (`Preferences`),...
5. **使用Maven构建**:在项目中,可以看到一个新的"Maven Build"配置选项。在这里,可以配置构建目标、执行的生命周期阶段(如"compile"、"package")以及任何额外的Maven命令行参数。 6. **依赖管理**:Maven通过...