WebServerException:无法启动嵌入式Tomcat



我想调试我的春季启动应用程序,但我无法在Intellij IDE上启动调试器模式。

我得到以下错误

Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
Picked up _JAVA_OPTIONS: -Xmx512M
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'jedisConnectionFactory' defined in class path resource [com/fedex/ground/transportation/fxglhlschedulesvc/config/RedisConfig.class]: Unsatisfied dependency expressed through method 'jedisConnectionFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisProperties' defined in file [C:Users3895631DesktopRepofxg-lhl-schedule-svcbuildclassesjavamaincomfedexgroundtransportationfxglhlschedulesvcconfigRedisProperties.class]: Unexpected exception during bean creation; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.redis.port' in value "${spring.redis.port}"
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisProperties' defined in file [C:Users3895631DesktopRepofxg-lhl-schedule-svcbuildclassesjavamaincomfedexgroundtransportationfxglhlschedulesvcconfigRedisProperties.class]: Unexpected exception during bean creation; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.redis.port' in value "${spring.redis.port}"
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.redis.port' in value "${spring.redis.port}"

RedisConfig类


@Configuration
@EnableRedisRepositories
public class RedisConfig {
@Value("${spring.redis.password:}")
private String redisPassword;
@Bean
@Primary
JedisConnectionFactory jedisConnectionFactory(RedisProperties redisProperties) {
RedisStandaloneConfiguration redisStandaloneConfiguration =
new RedisStandaloneConfiguration(redisProperties.getRedisHost(), redisProperties.getRedisPort());
redisStandaloneConfiguration.setPassword(RedisPassword.of(redisPassword));
return new JedisConnectionFactory(redisStandaloneConfiguration);
}
@Bean
public RedisTemplate<String, Object> redisTemplate(JedisConnectionFactory connectionFactory) {
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(connectionFactory);
return template;
}
}

RedisProperties类


@Configuration
public class RedisProperties {
private final int redisPort;
private final String redisHost;
public RedisProperties(
@Value("${spring.redis.port}") int redisPort,
@Value("${spring.redis.host:localhost}") String redisHost) {
this.redisPort = redisPort;
this.redisHost = redisHost;
}
public int getRedisPort() {
return redisPort;
}
public String getRedisHost() {
return redisHost;
}
}

应用-属性

spring:
profiles: local
redis:
host: localhost
port: 6340
application:
name: fxg-lhl-schedule-svc
server.port: 9092

在这一点上,我遵循并尝试了类似故障排除线程上的大多数解决方案,但到目前为止运气不佳。

我想知道如何解决这个问题?

提供如下默认值-

@Value("${spring.redis.port:6340}")

最新更新