Tag: 春天引导

在junit测试中,反应器switchifempty的行为不像预期的那样

我正在为下面提供的方法编写测试。 ` class ScrapedRecipeCache @Autowired constructor(private val cache: RecipeScrapingCacheService, private val recipeService: RecipeService) : ScrapedRecipeProvider { override fun provide(request: ScrapingRequest): Flux<ScrapedRecipe> = cache.retrieve(request.link) .doOnNext { println(it) } .flatMap { (link, _, recipeHash, error) -> recipeService.findByHash(recipeHash) .map { ScrapedRecipe(it, link, error)} .switchIfEmpty(cache.remove(request.link).then(Mono.empty())) } .flux() } `测试看起来如下: private val recipeFetched = Recipe("Tortellini", RecipeDifficulty.EASY, 15.0) val cacheContents = […]

Spring Boot 2&Spring 5错误服务index.html

我有一个简单的Spring启动应用程序写在Kotlin。 @SpringBootApplication class DemoApplication fun main(args: Array<String>) { SpringApplication.run(DemoApplication::class.java, *args) } @Controller class HomeController { @GetMapping("/") fun home() = "index.html" } 在resource/public文件夹我有index.html 。 但是,当我打开我的浏览器并键入localhost:8080/我得到了错误java.lang.IllegalStateException: Could not resolve view with name 'index.html'在运行的Spring启动控制台java.lang.IllegalStateException: Could not resolve view with name 'index.html' 。 我只想要最简单的代码possbile服务于index.html。 不应该那么辛苦? ;) 注意:我正在使用Spring-Web-Reactive

如何修复与Spring安全代理的val字段初始化?

考虑kotlin控制器类: @RestController @RequestMapping("/myPath/") open class MyController { private val s3AsyncClient: S3AsyncClient = S3AsyncClient.builder().build() //… @PostMapping("/indexing") @Secured("ROLE_USER") fun someFunction() { return s3AsyncClient.toString(); } } 这导致NullPointerException。 这是我在调试器中看到的: 但是,当@Secured被删除一切正常。 所以春天的安全代理似乎破坏了kotlin val的初始化。 有没有办法让他们一起工作?

用Kotlin解释@Configuration @AutoConfigureAfter

我是一个python开发人员,对于Spring引导和gradle是全新的。 不过,我很好,与Java和Kotlin尽我所能。 我试图在本地主机上运行Spring Boot应用程序(Kotlin)。 除了这些行外,Gradle构建工作正常 @Configuration @AutoConfigureAfter(DispatcherServletAutoConfiguration::class) open class Assembly : WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter() { . . 没有值传递给参数resourceProperties,mvcProperties,beanFactory …. 我明白WebMvcAutoConfigurationAdapter构造函数期望这些参数,但不应该通过注释@Configuration和@AutoConfigureAfter自动传递。 由于我是春季引导全新的,我不知道什么是错的,在哪里。 由于这段代码已经在生产中运行,所以我很困惑我是否缺少一些本地配置或者gradle conf或其他东西。