一尘不染

org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration上的错误处理条件

spring-boot

在将以下所示的2个依赖项添加到我的应用程序后,一切正常,我的会话数据被写入到本地Redis服务器,但是当我尝试指定不同的Redis服务器地址时,出现错误。我认为该错误与某些依赖性问题有关,但是我不知道如何解决此问题。

compile "org.springframework.boot:spring-boot-starter-data-redis-reactive:${springVersion}"
compile "org.springframework.session:spring-session-data-redis:${springVersion}"

启动时出错

java.lang.IllegalStateException:org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:64)上的org.springframework.boot.auto.config.context.PropertyPlaceholderAutoConfiguration.propertySourcesPlaceholderConfigurer上的错误处理条件autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE],位于org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108)〜[spring-
context-5.0.6.RELEASE.jar:5.0
.6.RELEASE]在org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:180)〜[spring-
context-5.0.6.RELEASE.jar:5.0.6.RELEASE]在org.springframework.context
.annotation.ConfigurationClassBeanDefinitionReader。loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:141)〜[spring-
context-5.0.6.RELEASE.jar:5.0.6.RELEASE]在org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:117)〜[spring
-context-5.0.6.RELEASE.jar:5.0.6.RELEASE],位于org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:328)〜[spring-
context-5.0.6.RELEASE.jar:
5.0.6.RELEASE],位于org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233)〜[spring-
context-5.0.6.RELEASE.jar:5.0.6.RELEASE]。
context.support.PostProcessorRegistrationDelegate。invokeorgDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273)〜[spring-
context-5.0.6.RELEASE.jar:5.0.6.RELEASE]在org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93)〜[spring
-context-5.0.6.RELEASE.jar:5.0.6.RELEASE],位于org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694)〜[spring-
context-5.0.6.RELEASE.jar:在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532)〜[spring-
context-5.0.6.RELEASE.jar:5.0.6.RELEASE]中的[5.0.6.RELEASE]。
boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:61)〜[spring-
boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]在org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)[spring-
boot-2.0.2.RELEASE。
jar:2.0.2.RELEASE]位于org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395)[spring-
boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]位于org.springframework.boot
.org.springApplication.run(SpringApplication.java:327)[spring-
boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]在org.springframework.boot.SpringApplication.run(SpringApplication.java:1255)[spring-
在org.springframework.boot.SpringApplication.run(SpringApplication.java:1243)的boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]
[spring-
boot-2.0.2.RELEASE.jar:2.0.2。释放],位于pl.bk.pizza.store.Initializer.main(Initializer.java:11)​​[classes
/:na]原因:java.lang.IllegalStateException:无法在org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:659)上从ClassLoader
[sun.misc.Launcher$AppClassLoader@18b4aac2]自检类[org.springframework.session.config.annotation.web.http.SpringHttpSessionConfiguration]
)〜[spring-
core-5.0.6.RELEASE.jar:5.0.6.RELEASE]在org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:556)〜[spring-
core-5.0.6.RELEASE。
jar:5.0.6.RELEASE]在org.springframework.org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:569)〜[spring-
core-5.0.6.RELEASE.jar:5.0.6.RELEASE]。
util.ReflectionUtils.doWithMethods(ReflectionUtils.java:541)〜[spring-
core-5.0.6.RELEASE.jar:5.0.6.RELEASE]在org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:599)〜
[spring-
core-5.0.6。RELEASE.jar:5.0.6.RELEASE],位于org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:724)〜[spring-
beans-5.0.6.RELEASE.jar:5.0.6.RELEASE
]在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:665)〜[spring-
beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]在org.springframework.beans.factory
.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:633)〜[spring-
beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] at
org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory。
java:1489)〜[spring-
beans-5.0.6.RELEASE.jar:5.0.6.RELEASE],网址为org.springframework.beans.factory.support.AbstractBeanFactory。isFactoryBean(AbstractBeanFactory.java:1012)〜[spring-
beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]在org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.addBeanTypeForNonAliasDefinition(BeanTypeRegistry.java:164)〜
org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.addBeanType(BeanTypeRegistry.java:153)上的[spring-
boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE]〜[spring-boot-
autoconfigure-
2.0.2.RELEASE.jar:2.0.2.RELEASE],位于org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.updateTypesIfNecessary(BeanTypeRegistry.java:203)〜[spring-
boot-autoconfigure-2.0.2.RELEASE.jar
:2.0.2.RELEASE],位于org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.getNamesForType(BeanTypeRegistry.java:115)〜[spring-
boot-
autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE]在org.springframework.boot。autoconfigure.condition.OnBeanCondition.collectBeanNamesForType(OnBeanCondition.java:265)〜[spring-
boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] at
org.springframework.boot.autoconfigure.condition.OnBeanCondition.getBeanNamesForType
(OnBeanCondition.java:254)〜[spring-boot-
autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE]在org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchingBeans(OnBeanCondition.java:196)
〜[spring-boot-
autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE]在org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:116)〜[spring-
boot-autoconfigure
-2.0.2.RELEASE.jar:2.0.2.RELEASE],位于org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47)〜[spring-
boot-autoconfigure-2.0.2.RELEASE。jar:2.0.2。[RELEASE]
…省略了17个公共框架造成原因:java.lang.NoClassDefFoundError:java.lang.ClassLoader.defineClass1(本机方法)处的javax
/ servlet / Filter(java.lang处的[na:1.8.0-internal])。
ClassLoader.defineClass(ClassLoader.java:763)〜[na:1.8.0-内部] at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)〜[na:1.8.0-内部]
at java.net
URLClassLoader.defineClass(URLClassLoader.java:467)〜[na:1.8.0-内部] at
java.net.URLClassLoader.access $ 100(URLClassLoader.java:73)〜[na:1.8.0-内部]
at java.net .URLClassLoader $
1.run(URLClassLoader.java:368)〜[na:1.8.0-internal] at
java.net.URLClassLoader $ 1.run(URLClassLoader.java:362)〜[na:1.8.0-internal]
at java .security.AccessController.doPrivileged(本机方法)〜[na:1.8.0-internal] at
java.net.URLClassLoader.findClass(URLClassLoader。java:361)〜[na:1.8.0-internal]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)〜[na:1.8.0-internal]
at sun.misc.Launcher $ AppClassLoader.loadClass(
Launcher.java:331)〜[na:1.8.0-内部]在java.lang.ClassLoader.loadClass(ClassLoader.java:357)〜[na:1.8.0-内部]在java.lang.ClassLoader.defineClass1(本机方法)java.lang.ClassLoader.defineClass(ClassLoader.java:763的[na:1.8.0-内部]〜java.security.SecureClassLoader.defineClass(SecureClassLoader.java)的[na:1.8.0-内部]
:142)〜[na:1.8.0-internal] at
java.net.URLClassLoader.defineClass(URLClassLoader.java:467)〜[na:1.8.0-internal]
at java.net.URLClassLoader.access $ 100(URLClassLoader。
java:73)〜[na:1.8.0-internal] at java.net.URLClassLoader $
1.run(URLClassLoader.java:368)〜[na:1.8.0-internal] at
java.net.URLClassLoader $
1。在java.security.AccessController.doPrivileged(本机方法)处运行(URLClassLoader.java:362)〜[na:1.8.0-内部]在java.net.URLClassLoader.findClass(URLClassLoader处运行[na:1.8.0-内部]
.java:361)〜[na:1.8.0-internal]在java.lang.ClassLoader.loadClass(ClassLoader.java:424)〜[na:1.8.0-internal]在sun.misc.Launcher
$ AppClassLoader.loadClass
(Launcher.java:331)〜[na:1.8.0-内部]在java.lang.ClassLoader.loadClass(ClassLoader.java:357)〜[na:1.8.0-内部]在java.lang.Class.getDeclaredMethods0
(本机方法)在java.lang.Class.privateGetDeclaredMethods(Class.java:2701)〜[na:1.8.0-内部]〜在java.lang.Class.getDeclaredMethods(Class的〜na:1.8.0-内部]。
java:1975)〜[na:1.8.0-internal] at
org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:641)〜[spring-
core-5.0.6.RELEASE.jar:5。0.6.RELEASE]
...省略了35个共同的框架,原因是:java.lang.ClassNotFoundException:java.net.URLClassLoader.findClass(URLClassLoader.java:381)上的javax.servlet.Filter〜[na:1.8.0-internal]在java.lang.ClassLoader.loadClass(ClassLoader.java:424)〜[na:1.8.0-internal]在sun.misc.Launcher
$ AppClassLoader.loadClass(Launcher.java:331)〜[na:1.8.0-内部] at
java.lang.ClassLoader.loadClass(ClassLoader.java:357)〜[na:1.8.0-内部]
…省略了63个共同的框架0-internal]在java.lang.ClassLoader.loadClass(ClassLoader.java:357)〜[na:1.8.0-internal]
…省略了63个共同的框架0-internal]在java.lang.ClassLoader.loadClass(ClassLoader.java:357)〜[na:1.8.0-internal]
…省略了63个共同的框架

RedisConfig

@Configuration
@EnableRedisHttpSession
public class RedisConfig
{
    @Bean
    LettuceConnectionFactory jedisConnectionFactory()
    {
        final RedisStandaloneConfiguration config = new RedisStandaloneConfiguration();
            config.setHostName("redis-19999.c14.us-east-1-2.ec2.cloud.redislabs.com");
            config.setPort(19999);
            config.setPassword(RedisPassword.of("***"));
        return new LettuceConnectionFactory();
    }
}

build.gradle文件

buildscript {
    ext.springVersion = '2.0.2.RELEASE'
    ext.gradleDocker = '1.2'
    repositories {
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath "se.transmode.gradle:gradle-docker:$gradleDocker"
        classpath "org.springframework.boot:spring-boot-gradle-plugin:$springVersion"
    }
}

plugins {
    id "org.sonarqube" version "2.6.2"
}

apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'groovy'
apply plugin: 'org.springframework.boot'
apply plugin: 'docker'
apply plugin: 'jacoco'

dependencies {

    // spring
    compile "org.springframework.boot:spring-boot-starter-webflux:${springVersion}"
    compile "org.springframework.boot:spring-boot-starter-data-mongodb-reactive:${springVersion}"
    compile "org.springframework.boot:spring-boot-starter-security:${springVersion}"
    testCompile "org.springframework.security:spring-security-test:${springSecurityTest}"
    testCompile "org.springframework.boot:spring-boot-starter-test:${springVersion}"
    compile "org.springframework.boot:spring-boot-starter-data-redis-reactive:${springVersion}"
    compile "org.springframework.session:spring-session-data-redis:${springVersion}"

    // utils
    testCompile "org.assertj:assertj-core:${assertJ}"
    compile "com.google.guava:guava:${guava}"
    compile "io.projectreactor:reactor-core:${reactor}"
    compile "io.reactivex.rxjava2:rxjava:${rxjava}"
    compile "commons-lang:commons-lang:${commonsLang}"
    compile "commons-validator:commons-validator:${commonsLangValidator}"
    compileOnly "org.projectlombok:lombok:${lombok}"

    // embedded mongo for tests
    testCompile "de.flapdoodle.embed:de.flapdoodle.embed.mongo:${embeddedMongo}"

    // spock
    compile "org.codehaus.groovy:groovy-all:${groovy}"
    testCompile "org.spockframework:spock-core:${spockCore}"
    testCompile "org.spockframework:spock-spring:${spockSpring}"
}

阅读 493

收藏
2020-05-30

共1个答案

一尘不染

这里发生了几件事。

您提供的日志表明javax.servlet.Filter类路径中缺少日志,而您的构建脚本和依赖项建议您构建Spring
WebFlux应用程序。我怀疑这是由于您使用@EnableRedisHttpSessionHttpSession不是在那儿?)显式配置了Spring
Session的Servlet支持@EnableRedisWebSession。更好的是,您应该将Spring Session配置留给Spring
Boot来自动配置-请参阅Spring Boot参考手册的Spring
Session专用部分

相同的建议(避免使用显式配置,请依赖自动配置)适用于您的Redis配置,即不需要该显式LettuceConnectionFactorybean。

此外,对于Spring Boot,强烈建议使用其依赖项管理,而不是显式提供依赖项的版本,至少对于Spring
Boot的依赖项管理所涵盖的依赖项而言。请参阅Boots参考手册的依赖性管理依赖性版本附录部分。最重要的是,您还应该强烈考虑使用Boot的启动程序,以确保将所有必需的依赖项都拉进了内部,请参阅启动程序专用部分

2020-05-30