title: Disable Spring Security via Java configuration?
body: <p>I have a Java application that uses Spring Security via Java configuration.</p>
  
  <p>What is the easiest method of switching the whole Spring Security on/off in compilation?</p>
  
  <p>So something like <a href="https://stackoverflow.com/questions/11227464/disable-spring-security-from-spring-security-xml-file">this</a>, but for a configuration that uses no XML.</p>
  
  <p>EDIT:</p>
  
  <p>After applying @Profile my code looks like:</p>
  
  <pre><code>@Configuration
  @Profile("SecurityOn")
  @EnableWebMvcSecurity
  public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
  </code></pre>
  
  <p>The problem is that if the profile "SecurityOn" is not activated, Spring Security uses some default configuration. Instead, how to turn Spring Security completely off in that case?</p>