我正在尝试使用两个不同的端口在Spring Boot中配置应用程序,但我还没有.我的第一个aproximation是两个控制器,我在两个控制器中用container.setPort(8080)定义了一个@Bean; 我的第二个aproximation已经添加了执行器依赖并改变了管理的端口,但我的应用程序没有运行."地址已在使用中:绑定",如何使用两个端口来配置应用程序?我想要一个端口用于管理员,另一个端口用于我的api的咨询.
如何在多个端口上运行 Spring Boot Web 应用程序?例如 8080 和 80
我怎样才能做到这一点?
应用程序属性
server.port=8080, 80
Run Code Online (Sandbox Code Playgroud) 我需要在 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 需要访问令牌进行身份验证。这是我需要访问令牌的地方。因此,交互本质上是服务-服务,而不是特定于用户的。