相关疑难解决方法(0)

使用两个端口配置Spring Boot

我正在尝试使用两个不同的端口在Spring Boot中配置应用程序,但我还没有.我的第一个aproximation是两个控制器,我在两个控制器中用container.setPort(8080)定义了一个@Bean; 我的第二个aproximation已经添加了执行器依赖并改变了管理的端口,但我的应用程序没有运行."地址已在使用中:绑定",如何使用两个端口来配置应用程序?我想要一个端口用于管理员,另一个端口用于我的api的咨询.

spring spring-boot spring-boot-actuator

11
推荐指数
3
解决办法
2万
查看次数

Spring Boot 多个端口?

如何在多个端口上运行 Spring Boot Web 应用程序?例如 8080 和 80
我怎样才能做到这一点?
应用程序属性

server.port=8080, 80
Run Code Online (Sandbox Code Playgroud)

port spring spring-boot application.properties

3
推荐指数
1
解决办法
5497
查看次数

如何使用 Spring Security 5 在 Spring Boot 应用程序(不是 Web 应用程序)中获取 oauth2 访问令牌

我需要在 Spring Boot 应用程序的服务层中获取访问令牌(grant_type = client_credentials),以与其他微服务(服务到服务交互)进行通信。这一层没有 spring http session 或 auth,我只有 client_id、client_secret 和 token url。这些属性在 application.properties 中设置为:

spring.security.oauth2.client.registration.auth1.client-id=***
spring.security.oauth2.client.registration.auth1.client-secret=***
spring.security.oauth2.client.registration.auth1.authorization-grant-type=client_credentials
spring.security.oauth2.client.provider.auth1.tokenUri=***
Run Code Online (Sandbox Code Playgroud)

这对于 Spring Security OAuth 来说似乎很简单,但对于 Spring security 却无法解决。参考了 Spring Security 5 的文档,但一切似乎都是在 Web 界面的上下文中。我知道我可以进行 http 调用来获取带有我所拥有的信息的令牌,但我想利用该框架......

场景:让我们调用这个 Spring Boot 应用程序服务 A。还有其他服务可能会调用 A 来处理 http 上的更新或发送有关 A 监听的主题的 kafka 消息。当 A 处理更新/消息时,它需要向服务 B 发送一些数据,而服务 B 需要访问令牌进行身份验证。这是我需要访问令牌的地方。因此,交互本质上是服务-服务,而不是特定于用户的。

java spring spring-security oauth-2.0 spring-boot

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