Maven使用tips(1)

1.使用Maven打出root.war以外的命名的war

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-war-plugin</artifactId>
				<version>${maven-war-plugin.version}</version>
				<configuration> 
     				<warName>pcc-service</warName> 
     				<webResources> 
      					<resource> 
       						<directory>src/main/webapp/WEB-INF</directory> 
       						<filtering>true</filtering> 
       						<targetPath>WEB-INF</targetPath> 
      					</resource>      					
     				</webResources> 
    			</configuration> 
			</plugin>

 

2.

如果父pom中使用的是<dependencies>....</dependencies>方式,则子pom会自动使用pom中的jar包;
如果父pom使用<dependencyManagement><dependencies>....</dependencies></dependencyManagement>

方式,则子pom不会自动使用父pom中的jar包,

这时如果子pom想使用的话,就要给出groupId和artifactId,无需给出version

 

3.当引用父pom.xml的依赖Jar时,没有加version时,报"dependencies.dependency.version is missing"的错

 

解决方法如下:

法一:Put the literal value of the version in the child pom

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
      <version>3.2.3.RELEASE</version>
      <scope>runtime</scope>
    </dependency>

 

方法2:Clear your .m2 cache normally located C:\Users\user.m2\repository.

              I would say I do this pretty frequently
              when I'm working in maven. Especially before committing so that

              I can be more confident CI will run.
              You don't have to nuke the folder every time, sometimes just your project packages

               and the .cache folder are enough.

方法3:Add a relativePath tag to your parent pom declaration

   <parent>
      <groupId>com.mycompany.app</groupId>
      <artifactId>my-app</artifactId>
      <version>1</version>
     <relativePath>../parent/pom.xml</relativePath>
    </parent>

 
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值