======================加载xml===========================================================
<build>
<finalName>test</finalName>
<!--
这样也可以把所有的xml文件,打包到相应位置。
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
<include>**/*.tld</include>
</includes>
<filtering>false</filtering><--这里是false,用true会报 数据库连接 错误-->
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
<include>**/*.tld</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
jdk插件: 1.7或者1.8
1 <plugin> 2 <groupId>org.apache.maven.plugins</groupId> 3 <artifactId>maven-compiler-plugin</artifactId> 4 <version>3.5.1</version> 5 <configuration> 6 <source>1.7</source> 7 <target>1.7</target> 8 <encoding>UTF-8</encoding> 9 </configuration> 10 </plugin>
优化:maven/conf/setttings.xml
1 <profile> 2 <id>jdk-1.7</id> 3 <activation> 4 <activeByDefault>true</activeByDefault> 5 <jdk>1.7</jdk> #指定jdk的版本为1.7, 6 </activation> 7 <properties> 8 <maven.compiler.source>1.7</maven.compiler.source> 9 <maven.compiler.target>1.7</maven.compiler.target> 10 <maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion> 11 </properties> 12 </profile>
tomcat插件: tomcat7:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<path>/ssm</path>
<port>8888</port>
</configuration>
</plugin>
问题1:
The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
在pom中添加如下代码:
1 <dependencies> 2 <dependency> 3 <groupId>junit</groupId> 4 <artifactId>junit</artifactId> 5 <version>4.9</version> 6 <scope>test</scope> 7 </dependency> 8 <dependency> 9 <groupId>javax.servlet</groupId> 10 <artifactId>servlet-api</artifactId> 11 <version>2.5</version> 12 <scope>provided</scope> 13 </dependency> 14 <dependency> 15 <groupId>javax.servlet</groupId> 16 <artifactId>jsp-api</artifactId> 17 <version>2.0</version> 18 <scope>provided</scope> 19 </dependency> 20 </dependencies>
问题2:
解决-Dmaven.multiModuleProjectDirectory system property is not set. Check $M2_HOME environment variable and mvn script match.
1.添加M2_HOME的环境变量
2.Preference->Java->Installed JREs->Edit 选择一个jdk,
添加 -Dmaven.multiModuleProjectDirectory=$M2_HOME
原文:https://www.cnblogs.com/xxblogs/p/11870798.html