我最近想将我的 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) 这些之间的主要区别是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 是什么意思?
我使用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 Boot 测试,我在其中注入并监视mongoDbChannel
bean。然后我尝试启动正常工作流程并验证是否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
我正在尝试 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 应用程序,用于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
文件夹?