Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/328.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 禁用Spring Boot hello world应用程序中的所有模块_Java_Spring_Spring Mvc_Spring Boot - Fatal编程技术网

Java 禁用Spring Boot hello world应用程序中的所有模块

Java 禁用Spring Boot hello world应用程序中的所有模块,java,spring,spring-mvc,spring-boot,Java,Spring,Spring Mvc,Spring Boot,我仅使用此依赖项: 我不需要任何过滤器,任何安全性,我希望在Spring收到请求并检查路由后,它将调用home方法 如何配置Spring Boot以禁用所有筛选器、所有安全性和所有内容?您可以使用安全性。忽略属性,或者您可以使用此配置接受所有请求(Spring Boot 1.4.2): 您可以使用security.ignored属性,也可以使用此配置(spring boot 1.4.2)接受所有请求: 不包括依赖项。请共享您正在使用的pom.xmlusing@M.Deinum我只有一个依赖项,并

我仅使用此依赖项:

我不需要任何过滤器,任何安全性,我希望在Spring收到请求并检查路由后,它将调用home方法


如何配置Spring Boot以禁用所有筛选器、所有安全性和所有内容?

您可以使用
安全性。忽略
属性,或者您可以使用此配置接受所有请求(Spring Boot 1.4.2):


您可以使用
security.ignored
属性,也可以使用此配置(spring boot 1.4.2)接受所有请求:


不包括依赖项。请共享您正在使用的pom.xmlusing@M.Deinum我只有一个依赖项,并且执行过滤器anyway@RavindraDevadiga我已经添加了dependenciesi,如果这是唯一的依赖项,那么没有安全性…通过不包括依赖项。请共享您正在使用的pom.xmlusing@M.Deinum我只有一个执行依赖项和筛选器anyway@RavindraDevadiga我添加了Dependencies如果这是唯一的依赖项,则没有安全性。。。
import org.springframework.boot.*;
import org.springframework.boot.autoconfigure.*;
import org.springframework.web.bind.annotation.*;

@RestController
@SpringBootApplication
public class Example {

    @RequestMapping("/")
    String home() {
        return "Hello World!";
    }

    public static void main(String[] args) throws Exception {
        SpringApplication.run(Example.class, args);
    }

}
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

@Configuration
@EnableWebSecurity
public class UnsafeWebSecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(final HttpSecurity http) throws Exception {
        // Accept all requests and disable CSRF
        http.csrf().disable()
            .authorizeRequests()
            .anyRequest().permitAll();

        // To be able to see H2 console.
        http.headers().frameOptions().disable();
    }

}