spring-boot 相关问题

Spring Boot可以轻松创建Spring驱动的生产级应用程序和服务,并且可以轻松实现。它采用了Spring平台的观点,以便新用户和现有用户可以快速获得他们需要的位。

IllegalStateException:无法自省类

我正在尝试在 SpringBoot 应用程序上实现扩展功能,其中 @ComponentScan 应该扫描类路径中存在的单独 jar 中的 bean 定义。 @Compone...

回答 1 投票 0

如何在 Java Spring 上等待订阅者完成 TEXT_EVENT_STREAM

使用返回字符串的 Stream API,我希望有一个函数可以在单个字符串上返回它们,并用分隔符分隔,当前使用订阅并附加到列表 使用返回字符串的 Stream API 时,我想要一个函数将它们返回到由定界符分隔的单个字符串上,当前使用订阅并附加到列表,但显然,因为异步不会等待它准备好返回该功能之前。 如何实现非异步方法? private String executeStream(String streamId, UserToken currentUserAndToken) { List<String> combinedString = new ArrayList<String>(); URI streamUri = UriComponentsBuilder.newInstance() .scheme("https") .host(host) .path(streamPath) .buildAndExpand(streamVariablesMap) .toUri(); webClientt.get() .uri(streamUri) .headers(h -> h.setBearerAuth(currentUserAndToken.getToken())) .accept(MediaType.TEXT_EVENT_STREAM) // for Server-Sent Events (SSE) .retrieve() .bodyToFlux(String.class) // convert the response body to a Flux .subscribe(data -> combinedString.add(data)); // < --- Here I want to combine all Data into single string return String.join(", ", combinedString); } 使用 .blockLast() 代替 .subscribe() 它将阻塞,直到你读完所有。这将使您的呼叫同步。请参阅https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Flux.html#blockLast--

回答 1 投票 0

如何让 Java Testcontainers 在 Spring Boot 中与 ComposeContainer 和 R2DBC Postgres 配合使用?

在本地运行我的代码效果非常好。为此,我将 R2DBC 与 postgres 一起使用。 我的正常 compose.yml 文件如下所示: 服务: 我的数据库: 容器名称:我的数据库 userns_mode:保持...

回答 1 投票 0

@Autowired 组件空

我不知道为什么,但我的@Autowired组件(jwtService)返回一个NullPointerException。 这是我的代码: 这是我的 JwtTokenValidator 类: @成分 @AllArgsConstructor @NoArgs构造函数 酒吧...

回答 1 投票 0

liquibase 从 3.6.3 升级到 4.9.1 导致执行已经执行的文件

我们正在升级 spring boot(2.1.6.Release 到 2.7.18),这又将 liquibase 从 3.6.3 升级到 4.9.1,从而执行已经执行的文件。 看起来像是新版本的

回答 1 投票 0

Spring Cloud Gateway MVC 中的简单发现客户端

虚拟线程的可用性让我想从反应式 Spring Cloud Gateway 切换到 MVC 版本。大部分代码的迁移很容易(更改一些类和方法名称,移动

回答 1 投票 0

FindAndModify 无法增加字段的值

我正在使用以下代码来更新集合中的令牌字段 - @覆盖 公共 TestObject issuesToken(long id, String objectId) { 查询查询 = new Query(); 标准 = 新

回答 1 投票 0

JdbcTemplate 中的多租户

我在我的项目中使用JdbcTemplate,我们需要在我们的项目中实现多租户。 现在我们只是创建一个 DataSource bean,然后将该数据源注入到

回答 2 投票 0

使用 gradle 8.6 创建 war 时出现问题,未创建 public/docs 文件夹

spring boot 2.7.6 在使用创建战争时遇到问题 asciidoctor.jvm.convert 2.4.0 和 spring 文档 2.0.5 测试 { 使用JUnitPlatform() outputs.dir snippetsDir } asciidoctor { 配置&q...

回答 1 投票 0

Spring boot 3.2 连接 Elasticsearch 7.X

elasticsearch server 版本为7.10.2,无法升级。 该应用程序是 Spring Boot 3.1 和 spring-data-elasticsearch 4.4 现在我要升级到 Spring Boot 3.2,但是...

回答 1 投票 0

如何解决 Spring 中 `@Qualifier` 注释中的“首字母小写”限制?

MRE: 控制器: @RestController 公共类 DITestRestController { 私人语言; @Autowired 公共 DITestRestController(@Qualifier("haskell") Lang...

回答 1 投票 0

如何在intellij / Eclipse中使用java程序刷新文件夹?

我目前正在开发一个 Spring Boot 项目,同时上传在 resources\static\images 中创建的图像,但是当我尝试显示图像时,它没有显示。刷新后

回答 2 投票 0

确保 Spring Boot 自定义启动器自动配置中的顺序

我正在编写一个自定义 Spring Boot 启动器,需要检查客户端应用程序上下文中的某些要求。我在 @Conditional 评估时使用自定义 Condition 类执行此操作。上...

回答 1 投票 0

如何修复 java.lang.NoClassDefFoundError: org/springframework/boot/Bootstrapper?

尝试将 spring-boot 从 2.5 升级到 2.6,遇到以下问题,不知道出了什么问题 下面是我们提到版本的一些依赖项,其他都是我们没有提到的版本...

回答 3 投票 0

访问令牌调用返回某些字段的空值

我使用 Spring Boot 和 Spring Security 以及 ms azure b2c 我得到一个访问令牌 GetTokenRequestPayload req = new GetTokenRequestPayload(GRANT_TYPE_CREDENTIAL,certSecretValue, clientId, graphAPI ?

回答 1 投票 0

Spring boot执行器MySQL数据库健康检查

我设计了一个演示 Spring Boot 应用程序与 MySQL 数据库的 CRUD 操作。我的 application.properties 文件如下。 spring.boot.admin.url=http://localhost:8081 spring.datasource.url=...

回答 6 投票 0

FTP 入站适配器在 SQS 消息发送后将文件发送到远程

我正在实现一个 @InboundChannelAdapter 场景,其中我需要在将消息发送到 AWS SQS 队列后将文件移动到远程存档目录。我已经成功实现了类似的场景

回答 1 投票 0

将 Spring Boot 从 3.2.5 迁移到 3.3.0 后测试失败

我将 Spring Boot 应用程序从版本 3.2.5 迁移到 3.3.0,突然间所有 WebMvcTest 测试都失败了。经过一些调试后,我发现问题出在自定义的 OncePerRequestFilter

回答 1 投票 0

IntelliJ 无法解析我的库中的类

我使用这些 pom.xml 创建了一个库: 我用这些 pom.xml 创建了一个库: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>3.3.0</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>spring.boot</groupId> <artifactId>jwt</artifactId> <version>0.0.1</version> <name>jwt</name> <description>A library of the boilerplate configuration for securing a Spring Boot API with JWT </description> <properties> <java.version>21</java.version> </properties> <packaging>jar</packaging> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <dependency> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt-jackson</artifactId> <version>0.11.5</version> </dependency> <dependency> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt-impl</artifactId> <version>0.11.5</version> <scope>runtime</scope> </dependency> <dependency> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt-api</artifactId> <version>0.11.5</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project> 我是通过mvn clean install打包的。然后,为了测试它,我将其添加到我的本地 Maven 存储库:~/.m2/repository,运行:mvn install:install-file -Dfile=jwt-0.0.1.jar -DgroupId=spring.boot -DartifactId=jwt -Dversion=0.0.1 -Dpackaging=jar,并将其包含在不同项目的 pom.xml 中,如下所示: <dependency> <groupId>spring.boot</groupId> <artifactId>jwt</artifactId> <version>0.0.1</version> </dependency> 但是,当我尝试使用库中的类时,IntelliJ 仍然显示 can't find symbol。 到目前为止我遇到的问题: 我已确认该库确实已保存到我本地的 Maven 存储库中 我已使缓存失效并重新启动了我的 IntelliJ 我还检查了我的 jar 的目录结构 我该如何解决这些问题? 转到:视图 -> 工具窗口 -> Maven 这对我有帮助。我认为IntelliJ有时不会自动更新内部库缓存。

回答 1 投票 0

在SpringBoot中自动装配bean时发出

我正在尝试使用 Spring boot JDBC 创建一个项目。 我已经用属性定义了所有必需的类。 但是当我运行该应用程序时,我收到 NullPointerException。 下面是代码:...

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.