我在jboss7服务器上部署了两个应用程序,一个springboot oauth应用程序(app1)和一个API应用程序(app2)使用它生成的令牌。这两个应用程序都部署和运行良好,但是当我部署app2和app1已经运行时,app1将无法示例化jwk控制器。
重新部署app1可修复此问题。但是部署app2总是会以相同的错误中断app1。
在jboss上部署spring oauth应用程序时需要额外的配置吗?
https://www.baeldung.com/spring-security-oauth2-jws-jwk
错误
Caused by: java.lang.RuntimeException: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'jwkSetController': Unsatisfied dependency expressed through field 'jwkSet'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jwkSet' defined in class path resource [oauth/config/OAuth2Conf.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.nimbusds.jose.jwk.JWKSet]: Factory method 'jwkSet' threw exception; nested exception is java.lang.NullPointerException
编码
@Bean
public JWKSet jwkSet() {
RSAKey.Builder builder = new RSAKey.Builder((RSAPublicKey) keyPair().getPublic())
.keyUse(KeyUse.SIGNATURE)
.algorithm(JWSAlgorithm.RS256)
.keyID(JWK_KID);
return new JWKSet(builder.build());
}
1条答案
按热度按时间nuypyhwy1#
我用2个不同的Spring配置文件(开发vs开发)部署了2个应用程序,这破坏了每个应用程序,并阻止它们一起部署。
TLDR:Active Spring Profiles应跨应用程序匹配
app1
./system-property=spring.profiles.active:add(value=“development”)
app2
./system-property=spring.profiles.active:add(value=“development”)