私が取り組んでいるかなり単純な Spring Boot アプリがあり、いくつかの Java Config クラスを使用しています。ただし、構成はピックアップされていないようです。いたるところにブレークポイントがありますが、何もトリップしません。RuntimeException
デバッガーがフリッツにあるかどうかを確認するために、数秒間投げさえしました。
私のメインクラスには、標準の Spring Boot メインがあります。
@ComponentScan
@EnableAutoConfiguration
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
ご覧のとおり、 と でタグ付けしまし@ComponentScan
た@EnableAutoConfiguration
。Application
クラスはクラスパスのルートにあります。注釈についての私の理解では、@ComponentScan
その下にあるすべての構成クラスを検索します。
1 層下のパッケージには、すべての構成クラスがあります。
私の「共通」構成
@Configuration
@EnableJpaRepositories("com.codechimp.XXX.repository")
@EnableTransactionManagement
public class AppCommonConfig {
@Inject
private Environment environment;
/* Define common beans here like datasource and such */
}
そして私のSpring Security構成
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Inject
private LocalXXXUserDetailsService localXXXUserDetailsService;
/**
* @see org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter#configure(HttpSecurity)
*/
@Autowired
protected void configure(HttpSecurity http) throws Exception {
// Configure http
}
/**
* @see org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter#configureGlobal(AuthenticationManagerBuilder)
*/
@Autowired
protected void configureGlobal(AuthenticationManagerBuilder auth)
throws Exception {
// Configure auth
}
}
ただし、アプリを実行すると、これらの構成クラスのいずれのメソッドも呼び出されないようです。あたかも完全に無視されているかのようです。私が言ったように、私はブレークポイントを設定し、次のようにすべてのメソッドの最初に RuntimeException をスローすることさえ試みました:
if (true)
throw new RuntimeException("Break!");
確かに、Java Config の使用経験はあまりありませんが、ドキュメントを何度も読み返しましたが、欠けている部分は見当たりません。