(1)mvn -v 查看maven版本java
(2)compile 编译web
(3)test 测试apache
(4)package 打包浏览器
(5)clean 删除targettomcat
(6)install 安装jar包到本地仓库中服务器
<mirror> <id>jboss-public-repository-group</id> <mirrorOf>central</mirrorOf> <name>JBoss Public Repository Group</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> </mirror> <mirror> <id>alimaven</id> <mirrorOf>central</mirrorOf> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/repositories/central/</url> </mirror>
1)新建maven项目框架
2)手动添加缺失文件夹jsp
3)部署tomcatmaven
<build> <plugins> <plugin> <artifactId>maven-source-plugin</artifactId> <version>2.4.0</version> <executions> <execution> <phase>package</phase> <goals>jar-no-fork</goals> </execution> </executions> </plugin> </plugins> </build>
<?xml version="1.0" encoding="UTF-8"?> <!--project是pom.xml的根元素,包含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"> <!--指定当前pom的版本,也是必不可少的元素--> <modelVersion>4.0.0</modelVersion> <groupId>反写的公司网址+项目名</groupId> <artifactId>项目名+模块名</artifactId> <!--第一个0表示大版本号 第二个0表示分支版本号 第三个0表示小版本号 0.0.1 snapshot 快照 alpha 内部测试 beta 公测 Release 稳定 GA 正式发布 --> <version>1.0-SNAPSHOT</version> <!--jar war zip pom--> <packaging>war</packaging> <name>项目描述名</name> <url>项目地址</url> <description>项目描述</description> <developers>开发人员列表</developers> <licenses>开源框架许可证信息</licenses> <organization>组织信息</organization> <!--依赖列表--> <dependencies> <!--依赖项--> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> <type></type> <!--依赖范围 test表示junit只在测试的依赖范围内有用,在main主代码中引用junit会报错--> <scope>test</scope> <!--设置依赖是否可选,有true和false,默认是false,子项目继承,若为true,子项目必须显示引入该依赖--> <optional>false</optional> <!--排除依赖传递列表--> <exclusions> <exclusion> </exclusion> </exclusions> </dependency> </dependencies> <!--依赖的管理,主要定义在父模块中,供子模块继承--> <dependencyManagement> <!--依赖列表--> <dependencies> <!--多个依赖,但这些依赖并不会被运行,不会被引入实际的依赖中--> <dependency> </dependency> </dependencies> </dependencyManagement> <!--对构件行为提供相应的支持--> <build> <!--插件列表--> <plugins> <plugin> <groupId></groupId> <artifactId></artifactId> <version></version> </plugin> </plugins> <!--一般用于子模块对父模块pom的继承--> <parent></parent> <!--用来聚合运行多个maven项目,使不少maven模块一块儿编译--> <modules> <module></module> </modules> </build> </project>
<dependency> <groupId>com.gc.C</groupId> <artifactId>C</artifactId> <version>1.0-SNAPSHOT</version> </dependency>
<dependency> <groupId>com.gc.B</groupId> <artifactId>B</artifactId> <version>1.0-SNAPSHOT</version> </dependency>
<dependency> <groupId>com.gc.B</groupId> <artifactId>B</artifactId> <version>1.0-SNAPSHOT</version> <exclusions> <exclusion> <groupId>com.gc.C</groupId> <artifactId>C</artifactId> </exclusion> </exclusions> </dependency>
<packaging>pom</packaging> <modules> <module>../A</module> <module>../B</module> <module>../C</module> </modules>
<packaging>pom</packaging> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <junit.version>4.11</junit.version> </properties> <dependencyManagement> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>${junit.version}</version> <scope>test</scope> </dependency> </dependencies> </dependencyManagement>
<parent> <groupId>com.gc.parent</groupId> <artifactId>parent</artifactId> <version>1.0-SNAPSHOT</version> </parent> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> </dependency> </dependencies>