Maven with Multi-module

Well, A project made of multi modules.

For example, the hongten-security project, the structure of the hongten-security project display as below(In eclipse tool):

and in the windows 7 operating system, the folder structure of the hongten-security project display as below,

then, you have TWO choices to run(or install) this project to you local liberary(repository).

The first one :

  Back to eclipse tool, select the "Package explorer" window, and select the "/hongten-sesurity/pom.xml" to run(or install) this project.

The second:

Back to Window 7 operating system, go to the directory "D:\Development\j2ee\workspace\hongten-sesurity", and open the command window to run(or install) this project.

I will display with the second method, and type the command "mvn install" in the command window.

WOW, there is an ERROR!!!!

The Maven can NOT find the parent.relativePath , it means that the "security-parent" model must install before you run(or install) the "hongten-security" project.

en, you should go to the derictory "D:\Development\j2ee\workspace\hongten-sesurity\security-parent" to install "security-parent" model.

After installing the "security-parent" model, rember to back to parent folder("D:\Development\j2ee\workspace\hongten-sesurity")

and type the command "mvn install"

============================================

Source Code

============================================

/hongten-sesurity/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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.b510.hongten</groupId>
  <artifactId>hongten-sesurity</artifactId>
  <version>0.0.1</version>
  <packaging>pom</packaging>

  <name>hongten-sesurity</name>
  <url>http://maven.apache.org</url>

  <modules>
      <module>security-parent</module>
      <module>security-configuration</module>
      <module>security-model</module>
      <module>security-web</module>
  </modules>
</project>

/security-configuration/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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.b510.hongten</groupId>
        <artifactId>security-parent</artifactId>
        <version>0.0.1</version>
    </parent>

    <artifactId>security-configuration</artifactId>
    <name>security-configuration</name>
    <packaging>jar</packaging>

</project>

/security-model/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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
      <groupId>com.b510.hongten</groupId>
      <artifactId>security-parent</artifactId>
      <version>0.0.1</version>
  </parent>

  <artifactId>security-model</artifactId>
  <name>security-model</name>
  <packaging>pom</packaging>

  <modules>
      <module>security-model-ai</module>
      <module>security-model-xml</module>
  </modules>
</project>

/security-model-ai/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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.b510.hongten</groupId>
        <artifactId>security-model</artifactId>
        <version>0.0.1</version>
    </parent>

    <artifactId>security-model-ai</artifactId>
    <name>security-model-ai</name>
    <packaging>jar</packaging>

</project>

/security-model-xml/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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.b510.hongten</groupId>
        <artifactId>security-model</artifactId>
        <version>0.0.1</version>
    </parent>

    <artifactId>security-model-xml</artifactId>
    <name>security-model-xml</name>
    <packaging>jar</packaging>

</project>

/security-parent/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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <!-- security-parent -->
    <groupId>com.b510.hongten</groupId>
    <artifactId>security-parent</artifactId>
    <version>0.0.1</version>
    <packaging>pom</packaging>

    <name>security-parent</name>
    <url>http://maven.apache.org</url>

    <!-- All properties declare here -->
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <junit.version>4.10</junit.version>
        <hibernate.core.version>3.6.10.Final</hibernate.core.version>
        <javassist.version>3.18.1-GA</javassist.version>
        <mysql.connector.version>5.1.33</mysql.connector.version>
        <log4j.version>1.2.17</log4j.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <!-- Configuration for Hibernate -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>${hibernate.core.version}</version>
        </dependency>
        <dependency>
            <groupId>org.javassist</groupId>
            <artifactId>javassist</artifactId>
            <version>${javassist.version}</version>
        </dependency>
        <!-- Configuration for mysql -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>${mysql.connector.version}</version>
        </dependency>
        <!-- Configuration for log4j -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>${log4j.version}</version>
        </dependency>
    </dependencies>
</project>

/security-web/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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.b510.hongten</groupId>
        <artifactId>security-parent</artifactId>
        <version>0.0.1</version>
    </parent>

    <artifactId>security-web</artifactId>
    <name>security-web</name>
    <packaging>jar</packaging>

</project>

Source Code Download : http://files.cnblogs.com/hongten/hongten-sesurity.rar

Source Code Download : http://files.cnblogs.com/hongten/hongten-sesurity_with_dependencyManagement.rar

========================================================

More reading,and english is important.

I‘m Hongten

E | [email protected]  B | http://www.cnblogs.com/hongten

========================================================

时间: 2024-10-03 16:45:24

Maven with Multi-module的相关文章

[maven] &quot;Dynamic Web Module 3.0 requires Java 1.6 or newer.&quot; OR &quot;JAX-RS (REST Web Services) 2.0 requires Java 1.6 or newer.&quot;

在网上下载的开源工程,用maven构建的时候报错: Dynamic Web Module 3.0 requires Java 1.6 or newer. JAX-RS (REST Web Services) 2.0 requires Java 1.6 or newer. 即使你把properties->Java Compiler->Complier compliance level设置为1.7或1.8也不管用. 解决方法: 第一步,在pom.xml中定义jdk的版本,如下 <build&

MAVEN Dynamic Web Module 3.0 requires Java 1.6 or newer.

MyEclipse2015中在使用Maven创建web项目时,会出现错误提示:Dynamic Web Module 3.0 requires Java 1.6 or newer. 解决方案: 在pom.xml文件中添加插件: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version&

maven 创建多module 项目

如何使用maven 来自为知笔记(Wiz)

使用Maven运行测试提示Module sdk 1.5的解决方法

解决方法: 1. 配置Project Structure 2. 在MAVEN_HOME/conf/setting.xml中添加profile 3. 在Maven项目的pom.xml文件里添加标签 三种方法都可以解决问题,推荐第三种方法. 原文地址:https://www.cnblogs.com/nemowang1996/p/10798128.html

学习 Maven之Maven Enforcer plugin

1.Maven Enforcer plugin是什么鬼? 在说这个插件是什么前我们先思考这么一个问题:当我们开发人员进入项目组进行开发前,要准备开发环境,而领导总是会强调工具的统一,编译环境的统一.比如要求所有开发人员使用JDK1.8进行开发. 开发人员接下来就是去下载指定版本的JDK,然后开始开发.但是如果开发人员的机器配置比较多,有好几个版本的JDK,而他虽然下载了JDK1.8,但是忘记配置环境变量,很有可能他用了JDK1.6进行的编译. 问题有了,该如何解决? Maven Enforcer

maven工程模块化

前言 项目的模块化有利于任务分工,后期维护,易扩展,模块还可以独立成服务单独部署等: 创建packaging类型为POM的父项目 我用的maven插件是m2e,相信大部分人在eclipse装的也是m2e插件:废话不说,直接开始: 菜单选择新建maven project,注意选择创建一个简单工程,如下图红圈所示,因为我们要创建的是packaging类型为pom的maven项目,自带的archetype里貌似没有对应的类型,反正我是没找到. 接着点击next,在packaging选项里选择pom,然

Apache Tomcat Maven Plugin

groupId and Mojo name change Since version 2.0-beta-1 tomcat mojos has been renamed to tomcat6 and tomcat7 with the same goals. You must configure your pom to use this new groupId: <pluginManagement> <plugins> <plugin> <groupId>org

maven 高级玩法

maven 高级玩法 标签(空格分隔): maven 实用技巧 Maven 提速 多线程 # 用 4 个线程构建,以及根据 CPU 核数每个核分配 1 个线程进行构建 $ mvn -T 4 clean install $ mvn -T 1C clean install 跳过测试 -DskipTests # 不执行测试用例,但编译测试用例类生成相应的 class 文件至 target/test-classes 下 -Dmaven.test.skip=true # 不执行测试用例,也不编译测试用例类

maven创建webapp项目

一.Eclipse配置 1.eclipse集成用户自己安装的jdk 2.eclipse集成用户自己安装的maven 3.eclipse集成用户自己安装的tomcat 4.去掉spell 5.修改字体 小四 二.maven创建webapp项目 new-->other-->maven project->use default workspace location(选择工作目录即可,不必命名项目文件夹)--> maven-archetype-webapp-->定义artifactI

项目管理及自动构建工具Maven

项目管理及自动构建工具Maven 一.Maven安装.目录结构.cmd命令1.下载安装apache-maven-3.2.3-bin.zip下载:http://maven.apache.org/download.cgi 安装:解压,配置环境变量M2_HOME=D:\Idea\config\apache-maven-3.2.3Path+=D:\Idea\config\apache-maven-3.2.3\bin 通过执行 mvn -v 可以查看当前版本号 C:\Users\yuki>mvn -v A