json-lib是一个java类库,提供将Java对象,包括beans, maps, collections, java arrays and XML等转换成JSON,或者反向转换的功能。json-lib其地址: http://json-lib.sourceforge.net/,执行环境需要以下类库支持:
• jakarta commons-lang 2.5 • jakarta commons-beanutils 1.8.0 • jakarta commons-collections 3.2.1 • jakarta commons-logging 1.1.1 • ezmorph 1.0.6
在maven项目pom.xml文件中增加如下内容:
<dependency> <groupId>net.sf.json-lib</groupId> <artifactId>json-lib</artifactId> <version>2.4</version> </dependency>
但是在执行install命令时找不到相应的jar包,具体错误信息如下:
[ERROR] Failed to execute goal on project cas-client-webapp: Could not resolve dependencies for project org.jasig.cas:cas-client-webapp:war:3.2.1: Failure to find net.sf.json-lib:json-lib:jar:2.4 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [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. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
这是因为json-lib提供了两个jdk版本的实现, json-lib-2.*-jdk13.jar和json-lib-2.*-jdk15.jar,需要增加classifier配置来解决问题,具体pom.xml文件增加如下信息即可:
<dependency> <groupId>net.sf.json-lib</groupId> <artifactId>json-lib</artifactId> <version>2.4</version> <classifier>jdk15</classifier> </dependency>