maven

maven web单模块

转载:      https://blog.csdn.net/yuguiyang1990/article/details/8796726

maven多模块

转载:    h--d/p/6001366.html


去仓库中删除  .last文件

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>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值