2016-08-15 3 views
0

以下の例外が発生しています。以下は例外を取得しますEmbeddedServletContainerFactory beanがないためにEmbeddedWebApplicationContextを開始できません

Caused by: org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean. 

私のbuild.gradleは、私のアプリケーションが非Webアプリケーションです

buildscript { 
    ext { 
     springBootVersion = '1.4.0.RELEASE' 
    } 
    repositories { 
     mavenCentral() 
    } 
    dependencies { 
     classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 
    } 
} 

ext { 
    aemVersion='1.0.25' 
    avroVersion = '1.8.0' 
    springWSVersion = '2.2.1.RELEASE' 
    jibxMinorVersion = "5" 
} 

apply plugin: 'java' 
apply plugin: 'eclipse' 
apply plugin: 'spring-boot' 

jar { 
    baseName = 'abc' 
    version = '0.0.1-SNAPSHOT' 
} 

sourceCompatibility = 1.7 
targetCompatibility = 1.7 

repositories { 
    flatDir { 
       dirs "${rootDir}/lib" 
      } 
    mavenLocal() 
    mavenCentral() 
    maven { 
    name 'springFramework' 
    url 'https://mvnrepository.com/artifact' 
    } 
} 

dependencies { 
    compile('org.apache.camel:camel-spring-boot-starter:2.17.2') 
    compile('org.apache.camel:camel-kafka:2.17.2') 
    compile group: 'org.apache.camel', name: 'camel-avro', version: '2.17.2' 
    compile "org.springframework.ws:spring-ws-core:$springWSVersion" 
    compile ('org.jdom:jdom:2.0.2') 
    compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.4' 
    compile group: 'org.springframework.integration', name: 'spring-integration-kafka', version: '2.0.0.RELEASE' 
    compile group: 'org.springframework.integration', name: 'spring-integration-core', version: '4.3.1.RELEASE' 
    compile group: 'org.apache.kafka', name: 'kafka_2.10', version: '0.8.0' 
    compile ('org.jibx:jibx-run:1.2.5'){ 
     exclude group: 'bcel', module: 'bcel' 
    } 
    testCompile ('org.jibx:jibx-extras:1.2.5'){ 
     exclude group: 'bcel', module: 'bcel' 
    } 
    compile("org.springframework.boot:spring-boot-starter") 
    testCompile('org.springframework.boot:spring-boot-starter-test') 
} 

です。私はコマンドラインからそれを実行し、次のコードを使用します。

@SpringBootApplication 
public class MyApplication implements CommandLineRunner{  
    @Autowired 
    private Executor routeExecutor; 

    public static void main(String[] args) { 
     SpringApplication.run(MyApplication.class, args); 
    } 
    @Override 
    public void run(String... args) throws Exception { 
     System.out.println("Running Application from run method.."); 
     this.routeExecutor.executeRoute(); 
    } 
} 

私は風袋を望んでいません。私はこの例外を探しましたが、それは一般的なものですが、非ウェブアプリケーションなので、 "spring-boot-starter-web"依存関係を追加したくありません。助けてください

+0

あなたがWebサービスを使用しているので、おそらくそれはです。春、駱駝、カフカ。おそらくそれらのうちのいくつかはWeb依存関係を追加しています。 – reos

答えて

1

Spring Bootは、あなたがクラスパス上にあるものに基づいてWebアプリケーションを構築しようとしていると誤って推測しています。あなたはSpringApplicationBuilderを使用して、あなたのmain方法でfalsewebを設定することで、それを修正することができます:

public static void main(String[] args) { 
    new SpringApplicationBuilder(MyApplication.class).web(false).run(args); 
} 
関連する問題