maven 打包时,jar should not point at files within the project directory 问题解决

原来是web项目,想通过自动部署插件把web项目打成war放到tomcat下 
在项目根部加了一个pom文件 
但打包的时候却报错 
should not point at files within the project directory 

<dependency>  
        <groupId>antlr</groupId>  
        <artifactId>antlr</artifactId>  
        <version>2.7.7</version> 
        <scope>system</scope>  
        <systemPath>${basedir}/src/main/webapp/WEB-INF/lib/antlr-2.7.7.jar</systemPath>  
    </dependency> 

解决方法之一

遵循以下用法:

用这种方式编写你的依赖关系

<dependency>
    <groupId>com.mylib</groupId>
    <artifactId>mylib-core</artifactId>
    <version>0.0.1</version>
</dependency>

然后添加maven-install-plugin

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-install-plugin</artifactId>
    <version>2.5.2</version>
    <executions>
        <execution>
            <id>install-external</id>
            <phase>clean</phase>
            <configuration>
                <file>${basedir}/lib/mylib-core-0.0.1.jar</file>
                <repositoryLayout>default</repositoryLayout>
                <groupId>com.mylib</groupId>
                <artifactId>mylib-core</artifactId>
                <version>0.0.1</version>
                <packaging>jar</packaging>
                <generatePom>true</generatePom>
            </configuration>
            <goals>
                <goal>install-file</goal>
            </goals>
        </execution>
    </executions>
</plugin>

然后运行mvn clean、mvn install

解决方法之二:将Jar包存入本地仓库,这样将自动从你的仓库中下载Jar包(推荐使用)

猜你喜欢

转载自blog.csdn.net/ke7in1314/article/details/79152461