過去 2 週間、私のアプリケーションは順調に進んでいます。昨夜、リモートでログインして、アプリケーションを実行すると、ApplicationContextProviderクラスがアプリケーション コンテキストの知識を失っていることを確認しました。PC の再起動に加えて、Maven のクリーン & ビルドを実行しました。揺れないみたい…
public class ApplicationContextProvider implements ApplicationContextAware {
    private static ApplicationContext applicationContext;
    public static ApplicationContext getApplicationContext() {
        return applicationContext;
    }
    public void setApplicationContext (ApplicationContext applicationContext) {
        this.applicationContext = applicationContext;
    }
}
私のメインクラス:
public static void main(String[] args) throws IOException {
    System.setProperty("java.util.logging.SimpleFormatter.format", "%4$s: %5$s%n");
    final HttpServer server = HttpServer.createSimpleServer(".", 80);
    WebappContext ctx = new WebappContext("ProductionQueue", "/");
    //enable annotation configuration
    ctx.addContextInitParameter("contextClass", "org.springframework.web.context.support.AnnotationConfigWebApplicationContext");
    ctx.addContextInitParameter("contextConfigLocation", "com.production");
    //allow spring to do all of it's stuff
    ctx.addListener("org.springframework.web.context.ContextLoaderListener");
    ....
    ctx.deploy(server);
    server.start();
    //start the production process
    Production.init();
    System.in.read();
    server.stop();
私の生産クラス:
public class Production {
    private static final Logger logger = Logger.getLogger(Production.class.getName());
    /* A list of active workflows */
    private static List<Workflow> workflowList = new ArrayList<Workflow>();
    private static ProductionService productionService;
    /**
     * Initialize the production line
     */
    public static void init() {
        logger.info("Initializing production workflows...");
        ApplicationContext context = ApplicationContextProvider.getApplicationContext(); //THIS IS NULL
        productionService = (ProductionService) context.getBean("productionService");
構成はまったく変更されていません。私の構成クラス内には、そのためのBeanがあります...
@Configuration
@ComponentScan(basePackages = {
        "com.production"
})
@PropertySource(value= {
        "classpath:/application.properties",
        "classpath:/environment-${FETTER_ENVIRONMENT}.properties"
})
@EnableJpaRepositories("com.production.repository")
@EnableTransactionManagement
public class Config {
    @Value("${db.url}")
    String PROPERTY_DATABASE_URL;
    @Value("${db.user}")
    String PROPERTY_DATABASE_USER;
    @Value("${db.password}")
    String PROPERTY_DATABASE_PASSWORD;
    @Value("${persistenceUnit.default}")
    String PROPERTY_DEFAULT_PERSISTENCE_UNIT;
    @Value("${hibernate.dialect}")
    String PROPERTY_HIBERNATE_DIALECT;
    @Value("${hibernate.format_sql}")
    String PROPERTY_HIBERNATE_FORMAT_SQL;
    @Value("${hibernate.show_sql}")
    String PROPERTY_HIBERNATE_SHOW_SQL;
    @Value("${entitymanager.packages.to.scan}")
    String PROPERTY_ENTITYMANAGER_PACKAGES_TO_SCAN;
    @Bean
    public ApplicationContextProvider applicationContextProvider() {
        return new ApplicationContextProvider();
    }