Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 将X-Frame-Options的配置更改为允许从时,Spring引导中出现异常_Java_Spring Boot_Iframe_Spring Security_X Frame Options - Fatal编程技术网

Java 将X-Frame-Options的配置更改为允许从时,Spring引导中出现异常

Java 将X-Frame-Options的配置更改为允许从时,Spring引导中出现异常,java,spring-boot,iframe,spring-security,x-frame-options,Java,Spring Boot,Iframe,Spring Security,X Frame Options,我在一个使用Spring Boot的项目中工作了一段时间,现在,作为一个需求,我使用一些需要呈现的html文件,其中一个使用iframe显示来自同一公司另一个业务部门但位于不同域的另一个web页面的信息 到目前为止,我在SpringConfiguration中所做的工作如下: @EnableWebSecurity @Configuration public class MyApplicationConfiguration extends WebSecurityConfigurerAdapter

我在一个使用Spring Boot的项目中工作了一段时间,现在,作为一个需求,我使用一些需要呈现的html文件,其中一个使用iframe显示来自同一公司另一个业务部门但位于不同域的另一个web页面的信息

到目前为止,我在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.
根据我在互联网和论坛上查看的内容,它应该可以正常工作,但它没有提到以下几点:

@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,因此我无法删除其中任何一个,只需添加即可。此外,我无法编辑或删除用作项目依赖项的组件上的注释

您会推荐什么其他解决方案?或者是否有解决此问题的方法

提前感谢您的时间和帮助。

Web安全配置器适配器的默认顺序为100,您的应用程序中似乎有两个:

com.sampleapp.myapp.ecards.MyApplicationConfiguration com.sampleapp.dep.dsp.core.autoconfigure.DsfCoreAutoConfiguration$DSFServerWebSecurityConfig 您应该将其中一个更新为使用@Order显式注释,并指定除100以外的值。鉴于上述限制,将@Order添加到com.sampleapp.myapp.ecards.MyApplicationConfiguration似乎更合适。它的顺序是高还是低将取决于安全配置的不同部分之间的关系,如果该配置重叠,您希望哪个优先