Java 部署在Tomcat中的Spring Boot应用程序:石英调度程序bean在@Service中不可见

Java 部署在Tomcat中的Spring Boot应用程序:石英调度程序bean在@Service中不可见,java,spring,tomcat7,Java,Spring,Tomcat7,使用SpringJavaConfig,在将我的war打包应用加载到Tomcat7中时,调度程序bean不可见 此配置正在另一个测试应用程序中运行。。。 我怎么能指出哪里出了问题 卡特琳娜产量: Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.quartz.Scheduler fr.myapp.schdtool.service.Sche

使用SpringJavaConfig,在将我的war打包应用加载到Tomcat7中时,调度程序bean不可见

此配置正在另一个测试应用程序中运行。。。 我怎么能指出哪里出了问题

卡特琳娜产量:

Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.quartz.Scheduler fr.myapp.schdtool.service.SchedulerService.scheduler; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.quartz.Scheduler] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
    ... 90 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.quartz.Scheduler] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1373)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1119)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545)
    ... 92 more
配置:

package fr.myapp;

import java.util.Properties;

import javax.sql.DataSource;

import org.hibernate.jpa.HibernatePersistenceProvider;
import org.postgresql.Driver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.SimpleDriverDataSource;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
@EnableWebMvc
@EnableTransactionManagement
@ComponentScan("fr.myapp")
public class WebAppConfig extends WebMvcConfigurerAdapter {
    @Autowired
    private ApplicationContext applicationContext;

    @Bean
    public DataSource dataSource() {
            SimpleDriverDataSource d = new SimpleDriverDataSource();
            d.setConnectionProperties(dProperties());
            d.setDriverClass(Driver.class);
            d.setUrl("jdbc:postgresql://localhost:5432/mydb");
            d.setUsername("BNF0016779");
            d.setPassword("");
            return d;
    }

    @Bean
    public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
            LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
            entityManagerFactoryBean.setDataSource(dataSource());
            entityManagerFactoryBean.setPersistenceProviderClass(HibernatePersistenceProvider.class);
            entityManagerFactoryBean.setPackagesToScan("fr.myapp");

            entityManagerFactoryBean.setJpaProperties(hibProperties());

            return entityManagerFactoryBean;
    }

    private Properties hibProperties() {
            Properties properties = new Properties();
            properties.put("hibernate.hbm2ddl.auto", "update");
            properties.put("hibernate.dialect", "org.hibernate.dialect.PostgreSQLDialect");
            properties.put("hibernate.show_sql", "false");
            return properties;        
    }

    private Properties dProperties() {
        Properties properties = new Properties();
        properties.put("spring.jpa.database", "POSTGRESQL");
        return properties;        
}   

    @Bean
    public SchedulerFactoryBean configureScheduler() {
        SchedulerFactoryBean f = new SchedulerFactoryBean();
        return f;
    }
}
编辑:服务

@Service
public class SchedulerService extends AbstractService implements ISchedulerService {
    @Autowired
    private Scheduler scheduler;

//Blah...
}
另一个问题:我的War是在War项目中生成的

Maven项目拱门:

-parent
+-war (just generates war)
+-web
我的war项目具有web依赖性 我的@Configuration类在web项目中

这可能是问题所在吗

编辑2:
显然,是的

考虑以下maven项目:

parent
+-war-project (just generates war)
+-web-project (web app project itself)

因为WAR是从WAR项目生成的,所以我需要在WAR项目中重新定义@SpringBootApplication类旁边的@Configuration类。

您能告诉我们您试图自动连接它的代码部分吗?我们能看到服务类吗?