spring-boot 相关问题

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

处理H2数据库中MySQL的date_format函数进行测试

我目前面临着测试在生产中使用 MySQL 的 Spring Boot 应用程序的挑战。具体来说,我在使用 date_format 函数时遇到了麻烦,该函数在 MySQ 中运行得很好......

回答 1 投票 0

Spring Boot @CrossOrigin 注解不起作用

我有一个 Angular 前端,它尝试调用 Spring Boot API,但由于 CORS 策略,请求被阻止。 我遵循了这个 Spring Boot 指南,它所说的只是添加 @

回答 1 投票 0

Hikari CP、Postgres - 警告日志“可能考虑使用较短的 maxLifetime 值”

我正在使用 Hikari 连接池和 Spring boot。我正在使用 hikari 连接池和带有默认配置的 postgres。 我看到很多如下警告 2023-01-31T06:07:54.4313140Z 2023-01-3...

回答 1 投票 0

处理H2数据库中MySQL的date_format函数以进行单元测试(Java)

我目前面临着对生产中使用 MySQL 的 Spring Boot 应用程序进行单元测试的挑战。具体来说,我在使用 date_format 函数时遇到了麻烦,该函数在...

回答 1 投票 0

使用mapstruct在另一个自定义映射器中使用自定义映射器(默认方法)

我想在MapperA的默认方法中使用MapperB 类似于这个问题: 如何在 mapstruct 中使用来自不同类的另一个映射 然而,据我所知,这个问题并没有要求“定制 m...

回答 2 投票 0

mybatis嵌套对象映射xml

我有一个问题困扰了我很多天。 我正在使用 mybatis 来编码 spring security。我想做的就是获取所有用户以及用户的角色。所以我尝试使用 mybatis 嵌套

回答 1 投票 0

如何绕过keycloak登录页面并使用spring security向客户提供建议的idp

我已经使用BFF中的Oauth2客户端功能使用kycloak配置了spring security,keycloak将扮演idp代理的角色,并且它已与microsoft配置成功(我们将...

回答 1 投票 0

WebClient 未以反应方式公开/返回数据

简而言之 我试图以反应方式使用 WebClient 来使用来自简单应用程序的数据,但数据是一次性返回的。 更多细节 有两个简单的 Spring React...

回答 1 投票 0

SpringBoot-2.1.3:使用 @Async 和 CompletableFuture 的并行方法调用不会在不同线程中调用

下面是我的代码,其中我尝试并行化 4 个方法调用,因为每个方法彼此独立并执行一些内存密集型统计操作。 @EnableAsync @

回答 3 投票 0

Spring Boot 3.1到3.3升级NoClassDefFoundError:RestTemplateExchangeTagsProvider

这个错误似乎来自某种类型的自动配置,但不知道如何解决它。 我可以看到这些类已被弃用,现在已被删除,但是依赖项正在尝试...

回答 1 投票 0

获取“规范中未定义操作!”对于 SpringDoc Swagger

我已经使用 OpenAPI 库实现了 swagger。 我的应用程序在 spring boot 2.7.1 上运行 我收到“规范中没有定义操作!”,甚至我的控制器也有 api。可能是什么...

回答 1 投票 0

导入 io.jsonwebtoken.security.Keys 时无法解析符号“security”;

我正在尝试使用 JWT 构建一个有关 API 身份验证的项目。为了做到这一点,我已经安装了版本 0.9.1 的 io.jsonwebtoken 包。 我的 pom.xml 我正在尝试使用 JWT 构建一个有关 API 身份验证的项目。为了做到这一点,我已经安装了版本 0.9.1 的 io.jsonwebtoken 包。 我的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>2.3.4.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.xyz</groupId> <artifactId>jwt_api_authentication</artifactId> <version>0.0.1-SNAPSHOT</version> <name>jwt_api_authentication</name> <description>Demo project for Spring Boot</description> <properties> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <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>org.springframework.security</groupId> <artifactId>spring-security-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> <optional>true</optional> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> </exclusion> </exclusions> </dependency> <dependency> <!-- JSON Web Token Support --> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt</artifactId> <version>0.9.1</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project> 当我尝试导入“io.jsonwebtoken.security.Keys”时,我收到此错误:“无法解析符号‘安全’”。 我尝试了 0.6.0 但仍然没有成功。 我该如何解决这个问题? 谢谢。 我的 pom.xml 中有此配置。这对我有用。我删除了问题中的依赖项,并将其替换为以下内容。 <dependency> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt-impl</artifactId> <version>0.11.5</version> </dependency> <dependency> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt-api</artifactId> <version>0.11.5</version> </dependency> <dependency> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt-jackson</artifactId> <version>0.11.5</version> </dependency> 编辑:2023 年 1 月 27 日 将答案中的库版本从早期的 0.11.1 更新到最新版本 0.11.5。 基于 https://search.maven.org/search?q=fc:io.jsonwebtoken.security.Keys%20AND%20g:io.jsonwebtoken(这是您获取具有特定的工件列表的方法) groupId 包含特定类),您至少需要 0.10.0 的jjwt-api 导入 0.10.0 ofjjwt-api 并为我工作

回答 3 投票 0

Spring Boot JMS 没有 JmsTemplate bean 可用

我正在尝试从我的应用程序使用 JMS 发送消息。 我在我的 pom 中添加 org.springframework spring-jms 我正在尝试从我的应用程序使用 JMS 发送消息。 我添加到我的pom中 <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jms</artifactId> </dependency> <dependency> <groupId>javax.jms</groupId> <artifactId>jms</artifactId> <version>1.1</version> </dependency> 春天开始说 JmsTemplate 和 ConnectionFactory 由 Spring Boot 自动创建。在这种情况下,ActiveMQ 代理以嵌入式方式运行。 在我的批处理编写器中 @Autowired JmsTemplate jmsTemplate, void writer(List<String> items) { jmsTemplate.convertAndSend(items); } 但是没有找到bean JmsTemplate 没有“org.springframework.jms.core.JmsTemplate”类型的合格 bean 可用:预计至少有 1 个有资格作为自动装配候选者的 bean 我尝试在@configuration中添加消息转换器 @Bean public MessageConverter jacksonJmsMessageConverter() { MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter(); converter.setTargetType(MessageType.TEXT); converter.setTypeIdPropertyName("_type"); return converter; } 我尝试添加@EnableJMS(即使它只是为了监听器......) 但是没用... 我不明白为什么,在教程上看起来很简单...... 为了工作,我们需要创建一个 jmsTemplate bean @Bean public ConnectionFactory getConnectionFactory() { TibjmsConnectionFactory connectionFactory = new TibjmsConnectionFactory(urlBrocker); return connectionFactory; } @Bean public JmsTemplate jmsTemplate() { JmsTemplate template = new JmsTemplate(); template.setConnectionFactory(getConnectionFactory()); template.setPubSubDomain(false); // false for a Queue, true for a Topic return template; } 在 Spring Boot 与 ActiveMQ Artemis 的上下文中,要求只是将 spring-boot-starter-artemis (撰写本文时为 v3.2.6)作为 Maven POM 中的依赖项。检测到 Artemis 位于类路径上时,Spring boot 将根据您在 application.properties 中的设置,在应用程序上下文中自动配置名为“jmsTemplate”和“jmsConnectionFactory”的两个 bean,例如 REMOTE Artemis 代理的示例(上面的 starter-artemis 依赖项仅适用于客户端,无嵌入式服务器): spring.artemis.mode=native spring.artemis.broker-url=tcp://localhost:8090?jms.clientID=myclientId spring.artemis.user=myuser spring.artemis.password=mypassword 注意:像spring.artemis.pool.enabled=true这样的额外参数可能会默默地破坏自动装配!!! 最小Spring boot应用程序可以像这样'ConnectorTestApplication.java': package broker.connectorTest; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jms.DefaultJmsListenerContainerFactoryConfigurer; import org.springframework.context.ApplicationContext; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.jms.annotation.EnableJms; import org.springframework.jms.config.DefaultJmsListenerContainerFactory; import org.springframework.jms.config.JmsListenerContainerFactory; import org.springframework.jms.core.JmsTemplate; import jakarta.jms.ConnectionFactory; @SpringBootApplication // is equivalent to @Configuration + @EnableAutoConfiguration + @ComponentScan @EnableJms public class ConnectorTestApplication { public static void main(String[] args) { ConfigurableApplicationContext ctx = SpringApplication.run(ConnectorTestApplication.class, args); // simplest example for sending one message JmsTemplate jmsTemplate = ctx.getBean(JmsTemplate.class); jmsTemplate.send("TestQ1",session -> session.createTextMessage("hello world!")); } @Bean // the Beans jmsConnectionFactory and jmsListenerContainerFactoryConfigurer (mapped to configurer arg of the same type) are created and auto-wired by Spring Boot auto-configuration public JmsListenerContainerFactory<?> myFactory(ConnectionFactory jmsConnectionFactory, DefaultJmsListenerContainerFactoryConfigurer configurer) { DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory(); // This provides all auto-configured defaults to this factory configurer.configure(factory, jmsConnectionFactory); return factory; } } 还有一个接收器'AsyncReceiver.java': package aero.champ.broker.connectorTest; import org.springframework.jms.annotation.JmsListener; import org.springframework.stereotype.Component; import jakarta.jms.JMSException; import jakarta.jms.Message; @Component public class AsyncReceiver { @JmsListener(destination = "TestQ1", containerFactory = "myFactory") public void receiveMessage(Message m) throws JMSException { System.out.println("Received <" + m.getBody(String.class) + ">"); } } 没有别的了! ...很神奇,但如果您没有正确的设置、依赖项或其他配置元素,则会很脆弱。

回答 2 投票 0

面临的问题是我无法使用 asciidoctor.jvm.convert 2.4.0 加载索引 html 中的 child.html

我正在使用 spring docs 2.0.5 发行版 我正在使用 gradle 8.6,我参考这个示例来配置 asciidoctor -i 参考下面的链接 https://github.com/spring-projects/spring-rest...

回答 1 投票 0

JSON 阅读器期待一个值,但发现“文档”

我正在尝试构建聚合管道,但它在某个地方引起了问题。为了调试这个问题,我尝试以 JSON 格式打印 MongoDB 查询。下面是代码的语法,它导致...

回答 1 投票 0

Spring-Integration 应用程序在迁移到 Azure Spring Apps 服务后缺少一些集成指标

我们有 Spring-Integration 微服务,它使用 JMS 来处理 MQ 消息。 消息管理器应用程序(另一个应用程序)对这个应用程序进行其余调用以获取有关成功和失败混乱的统计信息...

回答 1 投票 0

测试容器使用插入文档初始化 Mongo Db

我正在使用 testContanier 进行单元和集成测试。 我需要使用插入文档初始化 mongo db。如何在 Spring Boot 运行之前初始化 mongo db? @之前所有 公共静态无效

回答 1 投票 0

无法连接minikube后端服务

所以,我花了很多时间找不到解决方案。 场景:我正在玩 minikube。我有3个服务。一个是 mysql,另一个是前端,然后另一个是 springboot ......

回答 1 投票 0

如何从 AWS S3 加载 Spring Boot application.properties 作为 Spring 默认配置?

我们正在将 Spring Boot 应用程序从本地迁移到 Amazon Web Services。 Spring Boot application.properties 当前存在于本地服务器中。我们将放入 AWS S3 ......

回答 1 投票 0

Spring-boot GraphQl 输出映射到数据问题

我必须在数据对象中映射 graphql 响应。但最终,数据为空。 字符串文档 = """ 询问 { 条目(entry_ids:“12CA”){ rcsb_id

回答 1 投票 0

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