Java 禁用Spring Boot hello world应用程序中的所有模块
我仅使用此依赖项: 我不需要任何过滤器,任何安全性,我希望在Spring收到请求并检查路由后,它将调用home方法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 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();
}
}