小编Ale*_*der的帖子

有没有办法追踪maven pom中物业的来源?

我有一个复杂的maven项目,有很多托管依赖项,跟踪这些依赖项的版本有一点问题.例如,spring库的版本由属性值{spring.version}引导 - 但我不知道这个属性来自哪个项目.

使用mvn依赖:树我可以看到所有版本都已解决的最终结果,但它没有深入细节告诉我获胜依赖版本的来源,以及为什么该版本是赢家.

PS版本号不是来自我的父pom.

dependency-management pom.xml maven

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

在生产中运行 JUnit 集成测试的最佳方法

我是一名 Java 开发人员,而不是 QA 工程师,所以我的问题对某些人来说可能看起来微不足道。

如何在部署后运行集成测试?在正常的构建和部署过程中,所有 JUnit 测试都在部署之前执行。部署完成后,测试(据我理解)应该使用其他(黑盒)方法来完成。但是,如果我想使用一套不错的集成测试定期检查我的应用程序怎么办?

针对现有部署(包括生产)运行 IT 测试的正确方法是什么?

java junit integration-testing production-environment

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

SpringBootTest-如何在运行时配置中替换一个bean?

我正在为Spring Boot应用程序编写集成测试。只要我使用100%运行时配置进行测试,一切都会顺利进行。但是,当我尝试仅为该bean提供一个自定义bean时,一切都会中断。

@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class CombinedControllerIntegrationTest2 {

@TestConfiguration
static class ContextConfiguration {

    @Bean
    @Primary
    public SolrDocumentTypeMapRepository solrDocumentTypeMapRepository() {
        LOG.debug("SolrDocumentTypeMapRepository is being initialized.");

// etc.
Run Code Online (Sandbox Code Playgroud)

上面的代码变体导致实际的运行时SolrDocumentTypeMapRepository加载。我的测试类中的ContextConfiguration被忽略。

如果我尝试在内部ContextConfiguration上使用@Configuration而不是@TestConfiguration,则执行会陷入另一个极端-它以结尾

org.springframework.context.ApplicationContextException:由于缺少EmbeddedServletContainerFactory bean而无法启动EmbeddedWebApplicationContext。

因为,显然,其余配置未加载。

如果我尝试放

@ContextConfiguration(classes = {CombinedControllerIntegrationTest2.ContextConfiguration.class,GatewayApplication.class})

在我的主测试类上,它以与#1相同的方式失败-即,我的ContextConfiguration被忽略。

有任何想法吗?

PS我知道我可以使用@MockBean(甚至在其他情况下也可以使用),但是在这里,因为在某些时候我依赖于主代码中的@PostConsruct方法,所以@MockBeans毫无用处。

java testing spring integration-testing spring-boot

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

Java 8 DateTimeFormatter无法解析"Etc/GMT"时区

我正在尝试使用java.time.format.DateTimeFormatter来解析日期,如"2017-04-03 19:16:19 Etc/GMT"并获取 java.time.format.DateTimeParseException: Text '2017-04-03 19:16:19 Etc/GMT' could not be parsed at index 20

这是我的格式化程序的初始化方式:

DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss zzz");
Run Code Online (Sandbox Code Playgroud)

同时,如果日期如下:"2017-04-03 19:16:19 Etc/UTC ",一切都很好.

我检查了java.time.ZoneId.getAvailableZoneIds()- 字符串"Etc/GMT"在列表中(技术上,在Set中).

有任何想法吗?

java timezone parsing java-8

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