【发布时间】:2018-05-13 16:43:07
【问题描述】:
我在一个使用 Spring Boot 的项目中工作了一段时间,现在,作为一项要求,我正在使用一些需要渲染的 html 文件,其中一个使用 iframe 来显示另一个网页(来自同一公司的另一个业务部门,但在不同的域中)。
到目前为止,我在 SpringConfiguration 中所做的如下:
@EnableWebSecurity
@Configuration
public class MyApplicationConfiguration extends WebSecurityConfigurerAdapter {
@Value("${company.domain}")
private String companyDomain;
@Override
protected void configure(HttpSecurity http) throws Exception {
http.headers().frameOptions().disable().addHeaderWriter(new XFrameOptionsHeaderWriter(new StaticAllowFromStrategy(URI.create(this.companyDomain))));
}
}
根据我在互联网和论坛上检查的内容,它应该可以正常工作,但没有提及以下内容:
Error creating bean with name 'org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration': Injection of autowired dependencies failed; nested exception is java.lang.IllegalStateException: @Order on WebSecurityConfigurers must be unique. Order of 100 was already used on com.sampleapp.myapp.ecards.MyApplicationConfiguration$$EnhancerBySpringCGLIB$$24364a75@13ecedf6, so it cannot be used on com.sampleapp.dep.dsp.core.autoconfigure.DsfCoreAutoConfiguration$DSFServerWebSecurityConfig$$EnhancerBySpringCGLIB$$a540fd8@7ec416a0 too.
顺便提一下,我看到解决方案是在我的项目上下文中删除@Order 注释,但我的项目中没有任何@Order 注释。此外,这家公司的项目是使用一些预定义的 maven 原型创建的,这些原型将为所有软件组件创建自定义文件夹结构以及创建具有所有必需依赖项的 pom.xml(必须使用这些依赖项,所以我不能删除它们中的任何一个,只需添加)。此外,我无法编辑或删除用作项目依赖项的组件上的注释。
您会推荐什么其他解决方案?或者是否有任何解决方法可以解决此问题?
提前感谢您的时间和帮助。
【问题讨论】:
标签: java spring-boot iframe spring-security x-frame-options