Maven的依赖问题
在聚合模块时候,发现在父工程目录中的依赖存在一些问题。
依赖添加失败
* 在父工程的jar包依赖在子工程中无法进行添加报错*
Missing artifact com.github.pagehelper:pagehelper:jar:3.4.2-fix
原因
在父工程中已经确定jar的version,但是jar下载不下来,可能存在两种情况
1. 该jar包非免费,需要付费,所以下载不下来
2. 网络原因,连接不到国外的服务器
解决方案
1.去网上下载该jar包,手动导入Maven仓库中。
2.更换版本尝试,有可能行。
项目打包成war包失败(缺少web.xml)
web.xml is missing and () is set to true
* 解决方案
* : 右击项目名称 -> java EE Tools -> Generate Deployment Descriptor Stub
* 手动添加WEN-INF文件夹 和web.xml文件
添加Java编译器
<!-- java编译插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
配置Tomact
<pluginManagement>
<plugins>
<!-- 配置Tomcat插件 -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<path>/</path> <!--路径 -->
<port>8080</port> <!--端口 -->
</configuration>
</plugin>
</plugins>
</pluginManagement>
资源文件拷贝
<!-- 资源文件拷贝插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
Maven用命令启动tomact
总结
- Maven在项目中会遇到很多的问题,需要长期的经历才可以总结经验。
- 常见的错误大多是Missing**** 显示依赖不存在,报错等。
- 总之项目的错误需要大量的实战,日后将在会补充。