1. 打包或clean时报错:To see the full stack trace of the errors, re-run Maven with the -e switch
[WARNING] The requested profile "test" could not be activated because it does not exist. [ERROR] Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean (default-clean) on project stcs-monitor: Failed to clean project: Failed to delete C:UsersAdministratorworkspacestcs-monitor arget -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging.
原因:通过FTP工具上传到服务器时,打开了target下的classes里面的文件目录,这样的话,有时候会占用target下的文件,导致其他软件无法正常读取改文件,所以报错
2. svn同步时,一直显示target里面更新的class和其他文件
在eclipse中,右键点击目录 Team -> Set Property ... 然后在弹出的对话框中,Property name 选 “svn:ignore”,Property Content 输入:target
或,在Team Syn... 界面中,选中target下的文件目录,右键选择Add to svn:ignore
3. 启动报错:
严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1275) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1109) at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:520) at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:501) at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4639) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5179) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1403) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) 十一月 07, 2016 8:16:41 下午 org.apache.catalina.core.StandardContext listenerStart 严重: Error configuring application listener of class org.springframework.web.util.IntrospectorCleanupListener java.lang.ClassNotFoundException: org.springframework.web.util.IntrospectorCleanupListener
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1275) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1109) at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:520) at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:501) at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4639) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5179) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1403) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1393) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) 解决方法:
将项目 .classpath 文件中 <classpathentry exported="true" kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> <attributes> <attribute name="org.eclipse.jst.component.dependency" value="true"/> </attributes> </classpathentry> 改为: <classpathentry exported="true" kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> <attributes> <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/> </attributes> </classpathentry> 解决方案2:选中项目->右键Properties->选择Deployment Assemby->选择Add->选中Java Build Path Entries->Next->选择Maven Dependencies->Finish->Apply->OK PS:若 Maven Dependencies 已经存在,先选中remove掉,再ADD进去即可
4. Maven打包,没有把空文件打包出去,所以报错,找不到mybatis的mapping-xml文件夹
<!-- myBatis文件 --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <!-- 自动扫描entity目录, 省掉configuration.xml里的手工配置 --> <property name="mapperLocations" value="classpath:/com/kk/mapping/*Mapper.xml" /> </bean>
解决方法:在pom文件中配置,也打包空文件
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.4</version> <configuration>
<webXml>src/main/webapp/WEB-INF/web.xml</webXml> <!--注:这个参数maven-war-plugin 2.4或以上的版本才支持。 true:打包包含空文件夹 -->
<includeEmptyDirectories>true</includeEmptyDirectories> </configuration> </plugin>
5. 在eclipse的maven插件中搜寻本地仓库中的jar搜索不到的解决方案
原因是因为maven中的本地仓库的index索引没有更新,导致在eclipse的maven插件中搜索不到。
解决决方案: 1. 在eclipse中打开菜单 window-> show view –> other –> Maven -> maven repositories 打开之后,选择local repositories –> local repository ,右击,选择Build index.
2. 更新完索引之后,在通过右键单击pom.xml文件选择maven –> add dependency 或者是打开pom.xml文件,选择dependencies –>add 时,就可以搜索到本地仓库的jar包了。
3. 如果想搜索公服上的jar
就选择Global Repositories ->右击 update index. (此处更新比较慢,需要耐心等候)。
6. 打包,无法找到 json-lib的依赖