我无法创建 AADAuthenticationProperties 的 bean,原因是属性 activeDirectoryGroups 不能为空。
错误如下:
绑定(bind)到目标 org.springframework.boot.context.properties.bind.BindException:无法将“azure.activedirectory”下的属性绑定(bind)到 com.microsoft.azure.spring.autoconfigure.aad.AADAuthenticationProperties 失败:
Property: azure.activedirectory.activeDirectoryGroups
Value: null
Reason: no puede estar vacío
这是尝试过的两种方法:
//1st option
@Bean
@ConditionalOnMissingBean
public AADAuthenticationProperties aadAuthenticationPropertiesFactory() {
return new AADAuthenticationProperties();
}
//2nd option
@Bean
@ConditionalOnMissingBean
public AADAuthenticationProperties aadAuthenticationPropertiesFactory() {
AADAuthenticationProperties aadAuthenticationProperties = new AADAuthenticationProperties();
aadAuthenticationProperties.setactiveDirectoryGroups(new ArrayList<>());
return aadAuthenticationProperties;
}
但错误仍然相同,因此您知道什么是 activeDirectoryGroups 属性以及如何创建 AADAuthenticationProperties 的 bean 吗?我正在使用 Java 8。
非常感谢!
最佳答案
就像 @M.Deinum 在评论中所说,您只需要在 application.properties
中指定属性即可。该 bean 将由 azure 自动配置生成。引用这个document了解更多详情。
azure.activedirectory.active-directory-groups=group1, group2
关于azure - 如何创建 AADAuthenticationProperties (azure) 的 bean?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57370470/