Spring/Maven Exception - java.lang.ClassNotFoundException: org.springplugins.web.SelectedAnnotationHandlerMapping
附:由Maven管理的基于Spring架构的Web应用引起的Exception介绍如何将Maven 官方repository(mvnrepository.com)中缺少的jar包加入到本地Maven的repository中。
案例:研究Spring3.X MVC新特性
1. 在maven的pom配置文件中导入spring 的常规依赖和Spring的mvc依赖:
Spring的常规依赖:
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
spring mvc依赖
dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
由于还用到了JSP和JSTL标记库,并使用的是Tomcat6.0。导入其它相关包
<!-- JSTL tag library -->
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.1.2</version>
</dependency>
<!-- javax.servelt.HttpServletRequest -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
2.编码结束后,部署到Eclipse的Tomcat中。
在启动Tomcat6.0后,出现如下Exception:java.lang.ClassNotFoundException: org.springplugins.web.SelectedAnnotationHandlerMapping
然后由于项目是基于Maven的,就去maven的repository中(mvnrepository.com)中找这个缺少的类在哪个地方,找了半天,都找不到,包括去公司的nexus私服上,也找不到,后来在jarfinder中找到了这个jar,这个缺少的类是在springplugins.jar中。既然找到了这个类,要做的就是将这个类加到项目中,于是将这个jar加到本地的Maven Dependency中就是一个不错的选择。
如果想要将springplugins.jar加到Maven Dependency中,可以分为如下几步
1) mvn install:install-file -Dfile=path-to-your-artifact-jar -DgroupId=your.groupId -DartifactId=your-artifactId -Dversion=your-version -Dpackaging=jar
如:mvn install:install-file -Dfile=D:\springplugins.jar -DgroupId=com.wsheng -DartifactId=wsheng-springplugins -Dversion=1.0 -Dpackaging=jar
(需要注意的是,根据-Dfile=D:\springplugins.jar要求在命令行执行该命令时,目录必须在D盘下:可以简单的理解成:Jar包在哪里,就在哪里执行该命令是一个很不错的选择)
执行后可以看到类似下面的信息:
[INFO] Installing c:\springplugins.jar to c:\maven-repo\swang\ebox\com\wsheng\wsheng-springplugins\1.0\wsheng-springplugins-1.0.jar
[INFO] Installing C:\Users\swang6\AppData\Local\Temp\mvninstall989911758677694999.pom to c:\maven-repo\swang\ebox\com\wsheng\wsheng-springplugins\1.0\wsheng-springplugins-1.0.pom
看到这信息和Build Successfully的信息后,证明jar包已经成功加到本地的repository中。
2). 可以去maven的本地repository中check该jar包是否存在。
3). 在maven的pom.xml中导入该jar包
<dependency>
<groupId>com.wsheng</groupId>
<artifactId>wsheng-springplugins</artifactId>
<version>1.0</version>
<type>jar</type>
</dependency>
相关推荐
在apache-maven-3.5.2/conf/setting.xml中加入以下配置即可解决 alimaven aliyun maven http://maven.aliyun.com/nexus/content/repositories/central/ central junit junit Address/ ...
赠送Maven依赖信息文件:springfox-spring-webflux-3.0.0.pom; 包含翻译后的API文档:springfox-spring-webflux-3.0.0-javadoc-API文档-中文(简体)-英语-对照版.zip; Maven坐标:io.springfox:springfox-spring-...
Maven坐标:org.springframework:spring-messaging:4.3.12.RELEASE; 标签:springframework、spring、messaging、中英对照文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,...
Failure to transfer org.codehaus.plexus:plexus-archiver:pom:1.0 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update ...
java运行依赖jar包
Maven坐标:org.springframework.security:spring-security-crypto:5.5.2; 标签:springframework、security、spring、crypto、中文文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html...
赠送Maven依赖信息文件:springfox-spring-webmvc-3.0.0.pom; 包含翻译后的API文档:springfox-spring-webmvc-3.0.0-javadoc-API文档-中文(简体)-英语-对照版.zip; Maven坐标:io.springfox:springfox-spring-web...
赠送Maven依赖信息文件:spring-context-support-1.0.10.pom; 包含翻译后的API文档:spring-context-support-1.0.10-javadoc-API文档-中文(简体)版.zip; Maven坐标:...
赠送Maven依赖信息文件:sentinel-spring-webmvc-adapter-1.8.0.pom; 包含翻译后的API文档:sentinel-spring-webmvc-adapter-1.8.0-javadoc-API文档-中文(简体)版.zip; Maven坐标:...
赠送Maven依赖信息文件:springfox-spring-web-2.9.2.pom; 包含翻译后的API文档:springfox-spring-web-2.9.2-javadoc-API文档-中文(简体)版.zip; Maven坐标:io.springfox:springfox-spring-web:2.9.2; 标签:...
Maven坐标:org.springframework.data:spring-data-keyvalue:2.3.9.RELEASE; 标签:springframework、data、spring、keyvalue、中文文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html...
Maven坐标:org.springframework:spring-beans:5.2.0.RELEASE; 标签:springframework、spring、beans、中英对照文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览...
赠送Maven依赖信息文件:spring-cloud-starter-alibaba-nacos-discovery-2021.1.pom; 包含翻译后的API文档:spring-cloud-starter-alibaba-nacos-discovery-2021.1-javadoc-API文档-中文(简体)版.zip; Maven坐标:...
java运行依赖jar包
官网链接地址:http://repo1.maven.org/maven2/archetype-catalog.xml 百度云链接:https://pan.baidu.com/s/1dF8Qa9V 密码:37me
Maven坐标:org.springframework:spring-aop:5.0.10.RELEASE; 标签:spring、aop、springframework、jar包、java、API文档、中文版; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览...
Maven坐标:org.springframework:spring-beans:5.0.10.RELEASE; 标签:spring、beans、springframework、jar包、java、API文档、中文版; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可...
Maven坐标:org.springframework:spring-test:5.3.15; 标签:spring、test、springframework、jar包、java、中英对照文档; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 ...
idea创建Maven项目时,报错显示Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.0.2:resources,并且Maven插件内看不到 mybatis-generator。如下图: 折腾了好久发现配置放错地方了,...
maven-resources-plugin-2.4.1.jar