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>
<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>
问题可解决。