小编fac*_*off的帖子

如何修复无法找到meta.properties的嵌入式kafka中的错误

我正在尝试使用kafka,kafka-streams和cassandra对应用进行集成测试。但是,当我尝试设置测试类时,我遇到了2个错误:错误[main] BrokerMetadataCheckpoint:无法读取dir下的meta.properties文件错误[主要] KafkaServer:无法读取日志目录下的meta.properties

我正在使用spring-boot-starter 2.1.2,spring-boot-starter-test 2.1.2,spring-kafka 2.2.0,spring-kafka-test 2.2.0,apache.kafka-streams 2.1.0

尝试更改logs.dir和logs.dirs参数。使用@EnableKafka @EnableKafkaStreams

@RunWith(SpringRunner.class)
@SpringBootTest
@EmbeddedKafka(partitions = 3, controlledShutdown = false, count = 1, topics = {"zc.deviceposition"}, brokerProperties = {"listeners=PLAINTEXT://localhost:9092", "port=9092", "log.dir=/home/name/logs"})
@EmbeddedCassandra(timeout = 60000)
@CassandraDataSet(value = {"bootstrap_test.cql"}, keyspace = "statistics")
@ActiveProfiles("test")
@DirtiesContext
public class CassandraTripsAggregatorProcessorSupplierIntegrationTest {
  @Test
  public void someTest() {System.out.println("hello world");}
}
Run Code Online (Sandbox Code Playgroud)

我期望使用嵌入式kafka运行上下文,但是现在我收到一个错误,指出meta.properties不存在

spring-boot-test embedded-kafka spring-kafka-test

7
推荐指数
1
解决办法
820
查看次数

如何从 Spring Boot 获取操作系统环境变量?

我是java和spring框架的新手。我的问题是如何将 OS(ubuntu) 环境变量注入 spring boot bean。我试过的:

@Configuration
@EnableWebMvc
public class CorsConfig implements WebMvcConfigurer {
 @Value("${COMPONENT_PARAM_CORS}")
 private String COMPONENT_PARAM_CORS;

 @Override
 public void addCorsMappings(CorsRegistry registry) {
  registry.addMapping("/"+COMPONENT_PARAM_CORS);
 }
}
Run Code Online (Sandbox Code Playgroud)

导出 COMPONENT_PARAM_CORS=**

打印环境

告诉我它存在,但是当我尝试 mvn clean install 时:发生错误

java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanCreationException: Error 
creating bean with name 'corsConfig': Injection of autowired dependencies 
failed; nested exception is java.lang.IllegalArgumentException: Could not 
resolve placeholder 'COMPONENT_PARAM_CORS' in value "${COMPONENT_PARAM_CORS}"
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 
'COMPONENT_PARAM_CORS' in value "${COMPONENT_PARAM_CORS}"
Run Code Online (Sandbox Code Playgroud)

然后我的单元测试也下降了(我试图搜索这个错误,但所有主题都是旧的并且使用来自 application.properties 的参数,但我需要使用 …

java spring environment-variables

1
推荐指数
1
解决办法
5606
查看次数