(澳门博彩导航) Spring4 Failed to read candidate component class 问题
专业在线博彩导航
专业在线博彩导航
当前位置 : 专业在线博彩导航 > 澳门博彩导航

(澳门博彩导航) Spring4 Failed to read candidate component class 问题

使用 spring 4 搭建环境时报以下错误

Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: URL [jar:file:/Users/darren/.m2/repository/com/chejingji/monitor/monitor-dal/1.0/monitor-dal-1.0.jar!/com/chejingji/monitor/dal/mongo/dao/UserDAO.class]; nested exception is java.lang.ArrayIndexOutOfBoundsException: 828
    at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponentsClassPathScanningCandidateComponentProvider.java:303
    at org.springframework.data.repository.config.RepositoryComponentProvider.findCandidateComponentsRepositoryComponentProvider.java:121
    at org.springframework.data.repository.config.RepositoryConfigurationSourceSupport.getCandidatesRepositoryConfigurationSourceSupport.java:70
    at org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport.getRepositoryConfigurationsRepositoryConfigurationExtensionSupport.java:85
    at org.springframework.data.repository.config.RepositoryConfigurationDelegate.registerRepositoriesInRepositoryConfigurationDelegate.java:126
    at org.springframework.data.repository.config.RepositoryBeanDefinitionParser.parseRepositoryBeanDefinitionParser.java:71
    ... 63 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: 828
    at org.springframework.asm.ClassReader.<init>ClassReader.java:183
    at org.springframework.asm.ClassReader.<init>ClassReader.java:153
    at org.springframework.asm.ClassReader.<init>ClassReader.java:426
    at org.springframework.core.type.classreading.SimpleMetadataReader.<init>SimpleMetadataReader.java:53
    at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReaderSimpleMetadataReaderFactory.java:98
    at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReaderCachingMetadataReaderFactory.java:102
    at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReaderSimpleMetadataReaderFactory.java:93
    at org.springframework.core.type.filter.AbstractTypeHierarchyTraversingFilter.matchAbstractTypeHierarchyTraversingFilter.java:121
    at org.springframework.core.type.filter.AbstractTypeHierarchyTraversingFilter.matchAbstractTypeHierarchyTraversingFilter.java:105
    at org.springframework.data.repository.config.RepositoryComponentProvider$InterfaceTypeFilter.matchRepositoryComponentProvider.java:187
    at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.isCandidateComponentClassPathScanningCandidateComponentProvider.java:346
    at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponentsClassPathScanningCandidateComponentProvider.java:280

jar 包依赖关系为:

[INFO] com.chejingji.monitor:monitor-web:war:1.0
[INFO] +- com.chejingji.monitor:monitor-common:jar:1.0:compile
[INFO] |  +- org.springframework:spring-core:jar:4.1.4.RELEASE:compile
[INFO] |  |  \- commons-logging:commons-logging:jar:1.2:compile
[INFO] |  +- org.springframework:spring-web:jar:4.1.4.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-beans:jar:4.1.4.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-context:jar:4.1.4.RELEASE:compile
[INFO] |  +- org.springframework:spring-oxm:jar:4.1.4.RELEASE:compile
[INFO] |  +- org.springframework:spring-tx:jar:4.1.4.RELEASE:compile
[INFO] |  +- org.springframework:spring-jdbc:jar:4.1.4.RELEASE:compile
[INFO] |  +- org.springframework:spring-webmvc:jar:4.1.4.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-expression:jar:4.1.4.RELEASE:compile
[INFO] |  +- org.springframework:spring-aop:jar:4.1.4.RELEASE:compile
[INFO] |  |  \- aopalliance:aopalliance:jar:1.0:compile
[INFO] |  +- org.springframework:spring-context-support:jar:4.1.4.RELEASE:compile
[INFO] |  +- org.springframework:spring-test:jar:4.1.4.RELEASE:compile
[INFO] |  +- org.springframework.data:spring-data-mongodb:jar:1.6.1.RELEASE:compile
[INFO] |  |  \- org.springframework.data:spring-data-commons:jar:1.9.1.RELEASE:compile
[INFO] |  +- org.apache.httpcomponents:httpclient:jar:4.3:compile
[INFO] |  |  +- org.apache.httpcomponents:httpcore:jar:4.3:compile
[INFO] |  |  \- commons-codec:commons-codec:jar:1.6:compile
[INFO] |  +- org.apache.httpcomponents:httpclient-cache:jar:4.3:compile
[INFO] |  +- org.apache.httpcomponents:httpmime:jar:4.3:compile
[INFO] |  +- org.mybatis:mybatis:jar:3.2.4:compile
[INFO] |  +- org.mybatis:mybatis-spring:jar:1.2.2:compile
[INFO] |  +- mysql:mysql-connector-java:jar:5.1.34:compile
[INFO] |  +- com.alibaba:druid:jar:1.0.2:compile
[INFO] |  +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.13:compile
[INFO] |  |  \- org.codehaus.jackson:jackson-core-asl:jar:1.9.13:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.4.0:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.4.0:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-core:jar:2.4.0:compile
[INFO] |  +- log4j:log4j:jar:1.2.16:compile
[INFO] |  +- org.slf4j:slf4j-api:jar:1.7.1:compile
[INFO] |  +- org.slf4j:jcl-over-slf4j:jar:1.7.1:compile
[INFO] |  +- org.slf4j:slf4j-log4j12:jar:1.7.1:compile
[INFO] |  +- javax.servlet:javax.servlet-api:jar:3.1.0:compile
[INFO] |  +- org.apache.velocity:velocity:jar:1.7:compile
[INFO] |  |  +- commons-collections:commons-collections:jar:3.2.1:compile
[INFO] |  |  \- commons-lang:commons-lang:jar:2.4:compile
[INFO] |  +- velocity-tools:velocity-tools-generic:jar:1.2:compile
[INFO] |  +- velocity-tools:velocity-tools:jar:1.4:compile
[INFO] |  +- com.alibaba:fastjson:jar:1.1.15:compile
[INFO] |  \- org.mongodb:mongo-java-driver:jar:2.12.4:compile
[INFO] +- com.chejingji.monitor:monitor-dal:jar:1.0:compile
[INFO] +- com.chejingji.monitor:monitor-biz:jar:1.0:compile
[INFO] \- junit:junit:jar:4.11:test
[INFO]    \- org.hamcrest:hamcrest-core:jar:1.3:test

spring 配置文件为:

    <mongo:mongo id="mongo"  host="$!{mongodb_host}" port="${mongodb_port}" />

    <bean id="userCredentials" class="org.springframework.data.authentication.UserCredentials">
        <constructor-arg name="username"  value="$!{mongodb_username}"/>
        <constructor-arg name="password"  value="$!{mongodb_password}"/>
    </bean>

    <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
        <constructor-arg ref="mongo" />
        <constructor-arg value="$!{mongodb_database}" />
        <constructor-arg ref="userCredentials" />
    </bean>

    <mongo:mapping-converter base-package="com.chejingji.monitor.dal.mongo.entity"/>

    <mongo:repositories base-package="com.chejingji.monitor.dal.mongo.dao"/>

jdk 使用 1.8,求助各位大牛!!

从dependency tree似乎看不出问题,题主试试清理.m2并重新install。

这是个比较诡异的错误
Caused by: java.lang.ArrayIndexOutOfBoundsException: 828
at org.springframework.asm.ClassReader.ClassReader.java:183

我翻了下源代码,是在解析class文件时越出了class的长度。

请检查下这个文件
jar:file:/Users/darren/.m2/repository/com/chejingji/monitor/monitor-dal/1.0/monitor-dal-1.0.jar 里面的 com/chejingji/monitor/dal/mongo/dao/UserDAO.class

应该是jdk1.8的问题,你的java web 容器 不支持 jdk1.8导致的。

该答案已被忽略,原因:

栏目列表

广告位

专业在线博彩导航