本篇文章记录了在学习整合Maven和SSH过程中遇到的问题,有的问题能够解决,有的问题还不能解决。方法不一定适合所有的环境,但绝对是本人常遇到的常见异常,在这里做一个笔记和记录,也分享给大家,希望大家多多给出见解!
如果有不同的见解,请按照编号写出自己的见解吧!
1.ReasonPhrase: Forbidden:
|--- 1.注意用户的权限以及角色role的设置,一般是没有权限才会被禁止的。
2.Failed to collect dependencies:
|--- 1.需要把parent工程,也就是package是pom的那个工程先install一下,或者deploy
|--- 2.需要注意在设置的<profile>工厂里面是否可以访问,如果直接访问public分组,那么就要检查public分组是否添加了自己设置的工厂
3.child module ....pom.xml does not exist:
|---- 1.注意module的名称是否正确,有时候命名问题会导致找不到项目的
|---- 2.注意一开始项目命名的规则问题
4.Cannot detect Web Project version. Please specify version of Web Project through <version> configuration property of war plugin. E.g.: <plugin> <artifactId>maven-war-plugin</artifactId> <configuration> <version>3.0</version> </configuration> </plugin>
|---- 1.和第五条一样在pom.xml加入plugin多的定义即可
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<version>3.0</version>
</configuration>
</plugin>
5.Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on project marer-test-weixin: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode)
|---- 1.加入以下插件引用:主要是因为没有指定web.xml的位置,在pom.xml中加入
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<version>3.0</version>
<webXml>WebRoot\WEB-INF\web.xml</webXml><!-- 这里指定位置 -->
</configuration>
</plugin>
6.javax.servlet.jsp.PageContext cannot be resolved to a type
|---- 1.这是因为没有引入jsp-api引发的问题,在pom.xml引入:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
</dependency>
7.Failed to clean project: Failed to delete F:\project\Stest......\target
|---- 1.重新使用命令clean一遍即可
8.The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory
|---- 1.注意:jsp-api的依赖的scope一定要provide,即不打包进去,否则会和tomcat冲突
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<scope>provided</scope>
</dependency>
9.java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld
|---- 1.缺少Spring的aspects的jar包,在pom.xml中引入
|---- 2.注意Spring的ORM框架也要导入,读取配置文件失败,原因是因为不能给txManager和hibernate注入Bean
|---- 3.注意2:我在上面已经用全局变量指定了Spring的<version>...</version>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</dependency>
10.Spring注入失败,【在action中注入service的对象或在service中注入dao对象】发生空指针异常
|---- 1.首先需要确定你的配置文件是否起了作用:applicationContext.xml是否已经在使用了
|---- 2.确定所有的properties文件是正确无误的
|---- 3.确定是否使用了struts2-spring-plugin依赖:
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-spring-plugin</artifactId>
</dependency>
11.-Dmaven.multiModuleProjectDirectory system propery is not set. Check $M2_HOME environment variable and mvn script match.
|---- 1.eclipse中使用maven插件的时候,运行run as maven build的时候报错,是因为JDK有问题
|---- 2.如果确定自己的Eclipse中的Window->Preference->Java->Installed JREs 设置好对应的JDK环境
|---- 3.在Default VM arguments中加入:-Dmaven.multiModuleProjectDirectory=$M2_HOME
12.Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project jiabo-motor:Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepositor
|--- 1.deploy的设置没有设置好,这是因为在Maven中使用了Nexus中央仓库,但是在项目的pom.xml中没有设置
|--- 2.加入如下设置:【自己之前自定义的deploy的地址】
<!-- 设置deploy的地址 -->
<distributionManagement>
<repository>
<id>user-release</id>
<name>user release resp</name>
<url>http://localhost:8081/nexus/content/repositories/user-release/</url>
</repository>
<snapshotRepository>
<id>user-snapshot</id>
<name>user snapshot</name>
<url>http://localhost:8081/nexus/content/repositories/user-snapshot/</url>
</snapshotRepository>
</distributionManagement>
13. The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
|---缺少jstl的包,在pom.xml加入
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
14. SSH和SpringMVC框架在使用IDE自带的tomcat管理的情况下,需要加入Servlet.api以及设置他的声明周期为provide
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
15.overlay [ id com.6dianedu:liudian-web] is not a dependency of the project.
|---将需要打包的项目依赖进来,加入<type>war</type>属性
16.ArtifactDescriptorException: Failed to read artifact descriptor for org.apache.shiro:shiro-core:jar:${shiro.version}: ArtifactResolutionException: Failure to transfer org.apache.shiro:shiro-core:pom:${shiro.version} from http://localhost:8081/nexus/content/groups/public/ was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.shiro:shiro-core:pom:${shiro.version} from/to nexus
这是由于在pom.xml里面的依赖使用了定义的变量${shiro.version},但是却没有在<properties>...</properties>中进行定义,只要在pom.xml加上定义即可
<properties>
<shiro.version>1.2.3</shiro.version>
</properties>
转载自:http://blog.csdn.net/nthack5730/article/details/46633287