我在eclipse中使用Java 8。问题可能是Spring安全性还不支持Java 8吗?
12:13:44.226 [localhost-startStop-1] ERROR org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [C:\dev\workspace_professional_web_development\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\movierental\WEB-INF\classes\com\hemswortht\movierental\annotation\ReleaseYearConstraint.class]; nested exception is org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: file [C:\dev\workspace_professional_web_development\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\movierental\WEB-INF\classes\com\hemswortht\movierental\annotation\ReleaseYearConstraint.class]; nested exception is java.lang.IllegalArgumentException
和ReleaseYearConstraint.java ......
package com.hemswortht.movierental.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.validation.Constraint;
import javax.validation.Payload;
import javax.validation.ReportAsSingleViolation;
import com.hemswortht.movierental.validator.ReleaseYearConstraintValidator;
@Target({ ElementType.TYPE })
@Constraint(validatedBy = ReleaseYearConstraintValidator.class)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@ReportAsSingleViolation
public @interface ReleaseYearConstraint {
String message() default "You have specified invalid search input parameters.";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
}
答案 0 :(得分:1)
这一切都归结为构建中的依赖项版本管理。 我建议你看一下Spring为此提供的各种解决方案:
请注意,更改pom中依赖项的顺序并不能完全解决您的问题 - 您最好添加依赖项排除项。
答案 1 :(得分:0)
我明白了!所以基本上你必须使用Spring 4.如果你使用的是Java 8. Spring Security 3.2与Spring 4兼容,所以没关系。
所以我哪里出错?????
您需要确保Spring Security 3.2依赖项在pom中的Spring 4依赖项之后。否则所有弹簧版本都会解决为3.2.6 !!!卫生署。