gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 03:15:15 29 4
gpt4 key购买 nike

将下面显示的 2 个依赖项添加到我的应用程序后,一切正常,我的 session 数据被写入本地 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: Error processing condition on org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration.propertySourcesPlaceholderConfigurer at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:64) ~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:180) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:141) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:117) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:328) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:61) ~[spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE] at pl.bk.pizza.store.Initializer.main(Initializer.java:11) [classes/:na] Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.springframework.session.config.annotation.web.http.SpringHttpSessionConfiguration] from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2] at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:659) ~[spring-core-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:556) ~[spring-core-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:569) ~[spring-core-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:541) ~[spring-core-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:599) ~[spring-core-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:724) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:665) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] at 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] at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1012) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE] at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.addBeanTypeForNonAliasDefinition(BeanTypeRegistry.java:164) ~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.addBeanType(BeanTypeRegistry.java:153) ~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.updateTypesIfNecessary(BeanTypeRegistry.java:203) ~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.autoconfigure.condition.BeanTypeRegistry.getNamesForType(BeanTypeRegistry.java:115) ~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] at 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] at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchingBeans(OnBeanCondition.java:196) ~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:116) ~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47) ~[spring-boot-autoconfigure-2.0.2.RELEASE.jar:2.0.2.RELEASE] ... 17 common frames omitted Caused by: java.lang.NoClassDefFoundError: javax/servlet/Filter at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0-internal] at java.lang.ClassLoader.defineClass(ClassLoader.java:763) ~[na:1.8.0-internal] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java: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.run(URLClassLoader.java:362) ~[na:1.8.0-internal] at java.security.AccessController.doPrivileged(Native Method) ~[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-internal] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0-internal] at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0-internal] at java.lang.ClassLoader.defineClass(ClassLoader.java:763) ~[na:1.8.0-internal] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java: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.run(URLClassLoader.java:362) ~[na:1.8.0-internal] at java.security.AccessController.doPrivileged(Native Method) ~[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-internal] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0-internal] at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0-internal] at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0-internal] at java.lang.Class.getDeclaredMethods(Class.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 common frames omitted Caused by: java.lang.ClassNotFoundException: javax.servlet.Filter at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[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-internal] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0-internal] ... 63 common frames omitted



Redis配置
@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}"
}

最佳答案

这里有几件事情正在发生。

您提供的日志表明 javax.servlet.Filter类路径中缺少构建脚本和依赖项建议您构建 Spring WebFlux 应用程序。我怀疑这是由于您使用 @EnableRedisHttpSession 显式配置了 Spring Session 的 Servlet 支持。 (注意 HttpSession 在那里?)而不是 @EnableRedisWebSession .更好的是,您应该将 Spring Session 配置留给 Spring Boot 来自动配置它 - 参见 Spring Session dedicated section Spring Boot 的引用手册。

相同的建议(避免显式配置,依赖自动配置)适用于您的 Redis 配置,即不需要显式 LettuceConnectionFactory bean 角,扁 bean 。

此外,对于 Spring Boot,强烈建议使用其依赖项管理,而不是显式提供依赖项的版本,至少对于 Spring Boot 的依赖项管理涵盖的依赖项。引用 dependency managementdependency versions appendix Boot 引用手册的部分。最重要的是,您还应该强烈考虑使用 Boot 的启动器来确保所有必需的依赖项都被拉入 - 参见 starters dedicated section .

关于spring-boot - org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration 上的错误处理条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51590215/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com