maven下配置pom.xml
2017-06-28 16:37
232 查看
项目中用用到maven实现在线打包,所以也踩了不少坑。把遇到的问题和解决办法都贴出来,以作备忘。
遇到的问题:
缺少依赖库。解决办法:
在build标签中添加:
<plugin>
<groupId>org.apache.maven.plugins</groupId>^M
<artifactId>maven-compiler-plugin</artifactId>^M
<version>3.1</version>^M
<configuration>^M
<source>1.7</source>^M
<target>1.7</target>^M
<encoding>UTF-8</encoding>^M
<compilerArgs>^M
<arg>-verbose</arg>^M
<arg>-Xlint:unchecked</arg>^M
<arg>-Xlint:deprecation</arg>^M
<arg>-bootclasspath</arg>^M
<arg>${env.JAVA_HOME}/jre/lib/rt.jar</arg>^M
<arg>-extdirs</arg>^M
<arg>${project.basedir}/src/main/webapp/WEB-INF/lib</arg>^M
</compilerArgs>^M
</configuration>^M
</plugin>^M
在 <dependencies>标签中添加:
<dependency>^M
<groupId>htmlunit</groupId>^M
<artifactId>htmlunit</artifactId>^M
<version>2.21-OSGi</version>^M
<scope>system</scope>^M
<systemPath>${JAVA_HOME}/jre/lib/jce.jar</systemPath>^M
</dependency>
<dependency>
这里是插件(https://mvnrepository.com/这个网站找插件)
</dependency>
可以使maven调用jce.jar和rt.jar库。
log4j报错的方法:
找到log4j,替换其下的<scope>标签为<scope>compile</scope>。
可解决问题。
Tomcat运行报错,找不到文件什么的,那大多使打包的时候有些文件没有打包进去,解决方法:
在build标签下添加:
<finalName>epoch-webservice</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
显示
在build标签下添加:
<defaultGoal>compile</defaultGoal>
问题可解决。
遇到的问题:
缺少依赖库。解决办法:
在build标签中添加:
<plugin>
<groupId>org.apache.maven.plugins</groupId>^M
<artifactId>maven-compiler-plugin</artifactId>^M
<version>3.1</version>^M
<configuration>^M
<source>1.7</source>^M
<target>1.7</target>^M
<encoding>UTF-8</encoding>^M
<compilerArgs>^M
<arg>-verbose</arg>^M
<arg>-Xlint:unchecked</arg>^M
<arg>-Xlint:deprecation</arg>^M
<arg>-bootclasspath</arg>^M
<arg>${env.JAVA_HOME}/jre/lib/rt.jar</arg>^M
<arg>-extdirs</arg>^M
<arg>${project.basedir}/src/main/webapp/WEB-INF/lib</arg>^M
</compilerArgs>^M
</configuration>^M
</plugin>^M
在 <dependencies>标签中添加:
<dependency>^M
<groupId>htmlunit</groupId>^M
<artifactId>htmlunit</artifactId>^M
<version>2.21-OSGi</version>^M
<scope>system</scope>^M
<systemPath>${JAVA_HOME}/jre/lib/jce.jar</systemPath>^M
</dependency>
<dependency>
这里是插件(https://mvnrepository.com/这个网站找插件)
</dependency>
可以使maven调用jce.jar和rt.jar库。
log4j报错的方法:
找到log4j,替换其下的<scope>标签为<scope>compile</scope>。
可解决问题。
Tomcat运行报错,找不到文件什么的,那大多使打包的时候有些文件没有打包进去,解决方法:
在build标签下添加:
<finalName>epoch-webservice</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
显示
No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>.错误:
在build标签下添加:
<defaultGoal>compile</defaultGoal>
问题可解决。
相关文章推荐
- maven 配置篇 之pom.xml
- Maven 配置篇之 pom.xml
- maven中pom.xml配置详解
- maven 配置篇 之pom.xml
- maven pom.xml配置说明
- Maven系列--pom.xml 配置详解
- maven 配置篇 之pom.xml
- Maven教程初级篇02:pom.xml配置初步
- maven 配置之pom.xml(3)
- Maven 配置篇之 pom.xml
- maven 配置篇 之pom.xml(一)
- Maven教程初级篇02:pom.xml配置初步
- maven 配置篇 之pom.xml
- maven 配置篇 之pom.xml
- 大型Java项目中使用maven进行管理,pom.xml文件中build的配置
- maven 配置篇 之pom.xml
- Maven的配置文件pom.xml
- MAVEN配置文件pom.xml
- maven 配置篇 之pom.xml
- Maven系列2--pom.xml 配置详解