无法解析占位符“ spring.security.oauth2.client.provider.oidc.issuer-uri”,并且创建名称为“ securityConfiguration”的bean时出错

时间:2019-08-07 01:02:55

标签: jhipster okta

我创建了一个新的jhipster单项应用程序,它运行良好。但是,当我用okta尝试jhipster时,它会失败,并且会出现错误消息。使用okta,我无法在默认支架上启动jhipster。

我觉得我已经尽力解决了这个问题,但没有找到解决方案。我在Java 8、11和12下进行了尝试,但仍然遇到相同的问题。我检查了我的okta和应用程序配置。如果可能,请告知我常见或潜在的解决方案。我尝试覆盖配置和所有内容。

忽悠

  

org.springframework.beans.factory.BeanCreationException:创建名称为'securityConfiguration'的bean时出错:自动连接依赖项的注入失败;嵌套异常是java.lang.IllegalArgumentException:无法解析值为“ $ {spring.security.oauth2.client.provider.oidc.issuer-uri”的占位符'spring.security.oauth2.client.provider.oidc.issuer-uri' }“

     

使用jhipster应用程序可以正常运行预期结果。目前还没有用于Orka的带有jhipster的脚手架系统。

嘿,我确实添加了此功能,但它在春季仍然无法正常工作:

application:
   name: ServerBirdTheatre
 profiles:
   # The commented value for `active` can be replaced with valid Spring profiles to load.
   # Otherwise, it will be filled in by maven when building the JAR file
   # Either way, it can be overridden by `--spring.profiles.active` value passed in the commandline or `-Dspring.profiles.active` set in `JAVA_OPTS`
   active: #spring.profiles.active#
 jmx:
   enabled: false
 data:
   jpa:
     repositories:
       bootstrap-mode: deferred
 jpa:
   open-in-view: false
   properties:
     hibernate.jdbc.time_zone: UTC
   hibernate:
     ddl-auto: none
     naming:
       physical-strategy: org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
       implicit-strategy: org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
 messages:
   basename: i18n/messages
 main:
   allow-bean-definition-overriding: true
 mvc:
   favicon:
     enabled: false
 task:
   execution:
     thread-name-prefix: server-bird-theatre-task-
     pool:
       core-size: 2
       max-size: 50
       queue-capacity: 10000
   scheduling:
     thread-name-prefix: server-bird-theatre-scheduling-
     pool:
       size: 2
 thymeleaf:
   mode: HTML
security:
 oauth2:
   client:
     provider:
       oidc:
         issuer-uri: https://***.okta.com/oauth2/default
     registration:
       oidc:
         client-id: ***
         client-secret: *** ```
I changed the key so i didnt broadcast it publicly, but that is the config and it throws the error.

2 个答案:

答案 0 :(得分:1)

您的application.yml中应具有以下配置:

spring:
  security:
    oauth2:
      client:
        provider:
          oidc:
            issuer-uri: https://dev-737523.oktapreview.com/oauth2/default
        registration:
          oidc:
            client-id: 0oafx05pu2pxhjgkC0h7 
            client-secret: ozxBeuk7nE-oLhkUvINe1cxR3LITquTp7Jt2NvX7

我猜您仍然有{}${}占位符。有关更多信息,请参见https://developer.okta.com/blog/2019/04/04/java-11-java-12-jhipster-oidc

答案 1 :(得分:0)

好吧,我猜出来了。我清理并重建了整个环境,然后确保我的配置与显示的完全一样,并且该应用程序已开始运行java open jdk11。但是现在尝试登录时会收到invalid_id_token,但该应用程序确实已启动,但登录页面为坏了。

   security:
    oauth2:
      client:
        provider:
          oidc:
            issuer-uri: https://dev-992900.okta.com/oauth2/default
        registration:
          oidc:
            client-id: yourclientid
            client-secret: yoursecretkey