maven下配置pom.xml
遇到的問題:
缺少依賴庫。解決辦法:
在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>
可以使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>
問題可解決。
maven下配置pom.xml