在跟随该教程时遇到若干问题:《Maven搭建SpringMVC+Mybatis项目详解》
在这里总结一下问题和解决方法
1. 问题:Maven无法下载jar
原因:Maven默认中央仓库无法访问(这个地址时好时坏)
解决方法,配置国内的镜像
<mirrors>
<mirror>
<id>nexus-osc</id>
<mirrorOf>central</mirrorOf>
<name>Nexus osc</name>
<url>http://maven.oschina.net/content/groups/public/</url>
</mirror>
<mirror>
<id>nexus-osc-thirdparty</id>
<mirrorOf>thirdparty</mirrorOf>
<name>Nexus osc thirdparty</name>
<url>http://maven.oschina.net/content/repositories/thirdparty/</url>
</mirror>
</mirrors>
2. 问题:Maven自动部署插件(org.codehaus.cargo)报错
原因:未知
解决方法:换插件(换了之后还是报错,最后换了个版本才成功)
<!-- 部署至Tomcat -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://127.0.0.1/manager/text</url>
<server>tomcat7</server>
<path>/LKShopping</path>
<username>admin</username>
<password>admin</password>
</configuration>
</plugin>
3.问题:在写接口实现的时候为了便于观察给方法加上了注解@Override,结果报错:
查询后得知要JDK6之后才支持在实现接口时加上@Override注解,但是我的JDK是1.7的:
继续搜索答案,结果需要在 Windows->Preferences-->java->Compiler-->compiler compliance level 中选择 1.6以上,但是我发现我的是1.7,调成1.6还是没用又调回来:
最后看到一篇博客中说到在报错的工程上,鼠标右键选择 Properties-->Java Compiler-->compiler compliance level 中选择 1.6以上,成功解决
但是这时候又报错了:
好吧继续搜索问题,得到解决办法,右键项目“Properties”,在弹出的“Properties”窗口左侧,单击“Project Facets”,打开“Project Facets”页面。把java改成对应版本。
4.问题:在测试Spring和Mybatis配置报错, org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [calsspath:config.properties] cannot be opened because it does not exist
把spring.xml中的路径去掉classpath后解决:
5.问题:在测试Spring和Mybatis配置报错:
原因是mysql服务没启动......启动后解决
未完待续...