小编Rom*_*n T的帖子

Spring Boot 3.x 升级。无法解析 org.springframework.boot:spring-boot-gradle-plugin:3.0.1

我最近想将我的 kotlin 项目从 spring boot 2.7.x 升级到 3.0.1。我使用 Java 17 temurin,gradle 7.6。在 IntelliJ 中,我在通过 gradle 导入项目时收到以下错误消息:

A problem occurred configuring root project 'demo'.
> Could not resolve all files for configuration ':classpath'.
   > Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.0.1.
     Required by:
         project : > org.springframework.boot:org.springframework.boot.gradle.plugin:3.0.1
      > No matching variant of org.springframework.boot:spring-boot-gradle-plugin:3.0.1 was found. The consumer was configured to find a runtime of a library compatible with Java 11, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' …
Run Code Online (Sandbox Code Playgroud)

intellij-idea gradle spring-boot java-17

72
推荐指数
2
解决办法
6万
查看次数

项目反应堆。Mono.map() 与 Mono.flatMap()

这些之间的主要区别是Mono什么?从文档中,我读到了flatMap异步和map同步的行为。但这对我来说并没有真正意义 b/c Mono 是关于并行性的,这一点是不可理解的。有人可以用更容易理解的方式重新表述它吗?

然后在flatMap声明的文档中(https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html#flatMap-java.util.function.Function-):

Transform the item emitted by this Mono asynchronously, returning the 
value emitted by another Mono (possibly changing the value type).
Run Code Online (Sandbox Code Playgroud)

那里的另一个 Mono 是什么意思?

project-reactor spring-webflux

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

Spring中的MessageInterpolator

我使用Spring 3.1.1和Hibernate-validator 4.3.0.Final并且在更改默认的MessageInterpolator时遇到问题,它从ValidationMessages(在类路径中)获取验证消息.

我想使用ResourceBundleMessageInterpolator,它将从我的spring messageSource获取消息

我在application-context.xml中做了类似的事情:

<bean id="resourceBundleMessageInterpolator"
      class="org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator">
    <constructor-arg index="0">
        <bean class="org.springframework.validation.beanvalidation.MessageSourceResourceBundleLocator">
            <constructor-arg index="0" ref="messageSource"/>
        </bean>
    </constructor-arg>
</bean>
<bean id="validator"
      class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
    <property name="messageInterpolator" ref="resourceBundleMessageInterpolator"/>
</bean>
Run Code Online (Sandbox Code Playgroud)

当我在日志中启动我的Web应用程序时,我看到:

11:04:07,402 DEBUG [org.hibernate.validator.internal.engine.ConfigurationImpl] - 
Setting custom MessageInterpolator of type
 org.springframework.validation.beanvalidation.LocaleContextMessageInterpolator 
11:04:07,402 DEBUG [org.hibernate.validator.internal.engine.ConfigurationImpl] - 
Setting custom ConstraintValidatorFactory of type org.springframework .validation.beanvalidation.SpringConstraintValidatorFactory
Run Code Online (Sandbox Code Playgroud)

所以你可以看到,它不是我想要的ResourceBundleMessageInterpolator.它是LocaleContextMessageInterpolator

稍后,当我尝试验证某些内容时,我只是从ValidationMessages.properties获取消息,而不是来自spring消息源:

11:08:09,397 DEBUG [org.hibernate.validator.resourceloading.PlatformResourceBundleLocator] - 
ValidationMessages not found.
11:08:09,413 DEBUG [org.hibernate.validator.resourceloading.PlatformResourceBundleLocator] - 
org.hibernate.validator.ValidationMessages found.
Run Code Online (Sandbox Code Playgroud)

从application-context.xml可以看出我想使用MessageSourceResourceBundleLocator,但是它已经使用了,我不知道为什么要使用PlatformResourceBundleLocator

有任何想法吗?

spring hibernate-validator

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

验证期间的 @SpyBean 和 Mockito.any()

我遇到以下问题。我有一个 Spring Boot 测试,我在其中注入并监视mongoDbChannelbean。然后我尝试启动正常工作流程并验证是否send在 bean 上调用了该方法。

@RunWith(SpringRunner.class)
@SpringBootTest(classes = {MongoAsBackupConfig.class},
        properties = {},
        webEnvironment = SpringBootTest.WebEnvironment.NONE)
public class MongoAsBackupConfigTest {
    @SpyBean(name = "mongoDbChannel")
    private QueueChannel mongoDbChannel;

    @Autowired
    private DirectChannel mongoDbWithFailoverChannel;

    @DirtiesContext
    @Test
    public void shouldUseFallbackForFullQueue() throws InterruptedException {
        IntStream.rangeClosed(1, BACKUP_QUEUE_CAPACITY + OVERFILLING_CLICK_COUNT).forEach(someNumber ->
            mongoDbWithFailoverChannel.send(MessageBuilder.withPayload(createPayload(someNumber)).build()));
        verify(mongoDbChannel, times(BACKUP_QUEUE_CAPACITY)).send(Mockito.any());
    }
}
Run Code Online (Sandbox Code Playgroud)

结果,我收到any与具体参数值不匹配的错误消息。但通常any意味着参数的任何值。这里出了什么问题?

Argument(s) are different! Wanted:
mongoDbChannel.send(
    <any>
);
-> at MongoAsBackupConfigTest.shouldUseFallbackForFullQueue(MongoAsBackupConfigTest.java:67)
Actual invocation has different arguments:
mongoDbChannel.send(
    GenericMessage [payload=Click(...), headers={id=0eaa2317-b1b5-604d-65c5-78da521cd585, timestamp=1509085945379}],
    10
);
-> …
Run Code Online (Sandbox Code Playgroud)

integration-testing mockito java-8 springmockito spring-boot

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

微型宇航员。环境的记录器配置

我正在尝试 micronaut-framework (1.0.1),想知道是否有可能为某个环境配置一些记录器,就像我在 Spring Boot 中所做的那样:即对于环境(配置文件),prod我想要这个记录器配置。 application-prod.yaml:

logging:
  level:
    root: warn
    xyz.x: info
    xyz.x.processorcli.ProcessorCliApplication: warn
Run Code Online (Sandbox Code Playgroud)

spring-boot micronaut

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

在 docker-compose 中的 Spring Boot 应用程序中使用外部配置

我有一个 Spring Boot 应用程序,用于com.spotify.dockerfile-maven-plugin构建我的应用程序 org.rtu/some-importer 的 docker 映像

我的 docker-compose.yml 是:

version: '3'
services:
  some-importer:
    image: org.rtu/some-importer
    build: .
  zookeeper:
    image: wurstmeister/zookeeper
    ports:
      - "2181:2181"
  kafka: 
    image: wurstmeister/kafka
    ports:
      - "9092:9092"
    environment:
      KAFKA_ADVERTISED_HOST_NAME: 172.17.0.1
      KAFKA_CREATE_TOPICS: "test:1:1"
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
Run Code Online (Sandbox Code Playgroud)

我怎么能说的过程中docker-compose up,它应该使用一个外部config.properties/data/some-importer/config文件夹?

spring spring-boot docker-compose

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