maven web单模块
转载: https://blog.csdn.net/yuguiyang1990/article/details/8796726
maven多模块
maven module 和 maven project的关系!
多模块中, maven project是顶级的父maven项目, maven module是子maven项目(模块)。
在父pom中配置每个模块都需要的jar包等其他配置信息----jar:能直接被子项目继承的jar配置
<!-- 在父pom中的dependencies标签中的jar配置, 子pom会直接继承 -->
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
</dependency>
</dependencies>
jar:不能直接被子项目继承, 需要在子pom中指定groupId,artifactId,不需要配置version <!-- 父pom.xml中的配置
dependencyManagement中的jar,子pom中不会直接继承,
需要在子pom中配置相应jar包的groupId、 artifactId,不需要配置version,
子pom才会自动引用父pom中这个jar的配置 。
主要配置不是所有模块都依赖的jar,且可控制不同模块中到该jar的版本一致
-->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>maven.study</groupId>
<artifactId>demo.interface</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</dependencyManagement>
<!-- 子pom中,引用父pom中dependencyManagement下的jar, 不需要指定version, 下面案例引用的是接口子模块,可以直接引用 -->
<dependencies>
<dependency>
<groupId>maven.study</groupId>
<artifactId>demo.interface</artifactId>
</dependency>
</dependencies>
3.在父pom中指定jdk编译版本, 保存后每个子项目都需要更新maven的项目(右键-->maven-->update object configuration 不同版本的eclipse可能不一样,多次尝试下)
<build>
<plugins>
<!-- 指定jdk的编译版本,只能指定大版本,如:1.7, 不能指定具体的小版本,如:1.7.0_67 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
出现jsp报错
在pom中添加: <dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
</dependencies>