java - WebServerException:无法启动嵌入式 Tomcat
问题描述
我想调试我的 spring-boot 应用程序,但我无法在 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:\Users\3895631\Desktop\Repo\fxg-lhl-schedule-svc\build\classes\java\main\com\fedex\ground\transportation\fxglhlschedulesvc\config\RedisProperties.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:\Users\3895631\Desktop\Repo\fxg-lhl-schedule-svc\build\classes\java\main\com\fedex\ground\transportation\fxglhlschedulesvc\config\RedisProperties.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}")
推荐阅读
- c# - 当在特定日期未找到值时用于拆分日期范围的 C# 函数
- asp.net-mvc - ASP.NET MVC 运行同一网页的多个实例
- video - .mov 视频的浏览器支持
- c++ - QT Not Recognizing UTF-8 Encoding,适用于所有其他地方
- jquery - ::before 元素干扰 jQuery 选择器
- python - 在 Python 中使用 iCloud 发送电子邮件
- r - 如何解决线性回归时间序列分析中的“attr(data, "tsp") <- c(start, end, frequency) 中的错误:对象不是矩阵”?
- gpu - 在 IMX8 上测量 Vivante G7200L 的 FLOPS
- c# - 如何从 Gremlin.NET 批量向 gremlin 服务器添加顶点?
- mysql - 删除触发器之前的 msql 5.0 - 取消