title: Spring facet not working, intellij
body: <p>I had a project which worked, and then suddenly stopped. Spring was failing to inject </p>
  
  <pre><code>@Configuration
  @Order(2)
  public static class RegularSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter {
  
      @Inject
      private Environment env;
  
      @Inject
      private AjaxAuthenticationSuccessHandler ajaxAuthenticationSuccessHandler;
          //Could not autowire. No bean of name 'ajaxAuth..' type found
  ...
  </code></pre>
  
  <p>the <code>AjaxAuthenticationSuccessHandler</code> class looks like this</p>
  
  <pre><code>@Component
  public class AjaxAuthenticationSuccessHandler extends SimpleUrlAuthenticationSuccessHandler {
  
      @Autowired
      private UserRepository userRepository;
  ...
  </code></pre>
  
  <p>I discovered that the facet was configured, but the line where the file with the <code>main</code> method as well as <code>@ComponentScan</code> was red. </p>
  
  <p><a href="https://i.stack.imgur.com/ExJVv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ExJVv.png" alt="enter image description here"></a></p>
  
  <p>Is this related to my problem? How do inform Spring of the <code>ajaxAuth..</code> class? Even when I switch to a previously working branch, this happens.</p>
  
  <p>Here is <code>Application.java</code>:</p>
  
  <pre><code>@ComponentScan
  @EnableAutoConfiguration(exclude = {MetricFilterAutoConfiguration.class, MetricRepositoryAutoConfiguration.class})
  public class Application {
  
      private static final Logger log = LoggerFactory.getLogger(Application.class);
  
      @Inject
      private Environment env;
  
      @PostConstruct
      public void initApplication() {
          if (env.getActiveProfiles().length == 0) {
              log.warn("No Spring profile configured, running with default configuration");
          } else {
              log.info("Running with Spring profile(s) : {}", Arrays.toString(env.getActiveProfiles()));
          }
      }
  
      /**
       * Main method, used to run the application.
       */
      public static void main(String[] args) throws UnknownHostException, NoSuchAlgorithmException {
          if (Cipher.getMaxAllowedKeyLength("AES") &lt;= 128) {
              log.error("You need Java Cryptography Extension (JCE) to run the system");
              return;
          }
  
          TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
          System.setProperty("user.timezone", "UTC");
          SpringApplication app = new SpringApplication(Application.class);
          app.setShowBanner(false);
  
          SimpleCommandLinePropertySource source = new SimpleCommandLinePropertySource(args);
  
          // Check if the selected profile has been set as argument.
          // if not the development profile will be added
          addDefaultProfile(app, source);
          addLiquibaseScanPackages();
          Environment env = app.run(args).getEnvironment();
  //      System.setProperty("javax.net.ssl.trustStore", env.getProperty("server.ssl.key-store"));
  //      System.setProperty("javax.net.ssl.trustStorePassword", env.getProperty("server.ssl.key-store-password"));
  
          String httpPort = env.getProperty("httpPort");
          String httpsPort = env.getProperty("server.port");
  
          String div = "----------------------------------------------------------";
          String local = "\tLocal: \t\thttps://127.0.0.1:" + httpsPort;
          String external = "\tExternal: \thttps://" + InetAddress.getLocalHost().getHostAddress() + ":" + httpsPort;
  
          if (httpPort != null) {
              div += "-----------------------------";
              local += " &amp; http://127.0.0.1:" + httpPort;
              external += " &amp; http://" + InetAddress.getLocalHost().getHostAddress() + ":" + httpPort;
          }
  
          log.info("Access URLs:\n" + div + "\n" + local + "\n" + external + "\n" + div);
      }
  
      /**
       * Set a default profile if it has not been set
       */
      private static void addDefaultProfile(SpringApplication app, SimpleCommandLinePropertySource source) {
          if (!source.containsProperty("spring.profiles.active")) {
              app.setAdditionalProfiles(Constants.SPRING_PROFILE_DEVELOPMENT);
          }
      }
  
      /**
       * Set the liquibases.scan.packages to avoid an exception from ServiceLocator.
       */
      private static void addLiquibaseScanPackages() {
          System.setProperty("liquibase.scan.packages", Joiner.on(",").join(
              "liquibase.change", "liquibase.database", "liquibase.parser",
              "liquibase.precondition", "liquibase.datatype",
              "liquibase.serializer", "liquibase.sqlgenerator", "liquibase.executor",
              "liquibase.snapshot", "liquibase.logging", "liquibase.diff",
              "liquibase.structure", "liquibase.structurecompare", "liquibase.lockservice",
              "liquibase.ext", "liquibase.changelog"));
      }
  
  }
  </code></pre>