2017-10-27 10 views
0

SpringブートプロジェクトでWildFlyを使用しようとしています。SpringブートアプリケーションプロジェクトでWildflyを使用する

マイApplicaion.java:

@EnableScheduling 
@ComponentScan 
@EnableAutoConfiguration 
@SpringBootApplication 
public class Application extends SpringBootServletInitializer { 
    public static HashMap<String, String> configuration = null; //set in SecurityConfig 

    @Override 
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { 
     return application.sources(Application.class); 
    } 

    public static void main(String[] args) { 
     // will ran the application . build all singleton beans 
     SpringApplication.run(Application.class, args); 
    } 

私のpom.xml:私は私のアプリを実行すると

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>com.testproj.myapp</groupId> 
    <artifactId>my test app</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <packaging>war</packaging> 

    <name>test app</name> 
    <description></description> 

    <parent> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-parent</artifactId> 
     <version>1.5.2.RELEASE</version> 
     <relativePath/> <!-- lookup parent from repository --> 
    </parent> 

    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> 
     <java.version>1.8</java.version> 

    </properties> 

    <dependencies> 
     <dependency> 
      <groupId>com.google.code.gson</groupId> 
      <artifactId>gson</artifactId> 
     </dependency> 

     <!-- mariadb-java-client IS LOADED DYNAMICALLY --> 
     <!--dependency> 
      <groupId>org.mariadb.jdbc</groupId> 
      <artifactId>mariadb-java-client</artifactId> 
      <version>1.1.7</version> 
     </dependency--> 

     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-security</artifactId> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-data-jpa</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-jdbc</artifactId> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-web</artifactId> 

      <exclusions> 
       <exclusion> 
        <groupId>org.springframework.boot</groupId> 
        <artifactId>spring-boot-starter-tomcat</artifactId> 
       </exclusion> 
      </exclusions> 
     </dependency> 

<dependency> 
<groupId>javax.servlet</groupId> 
<artifactId>javax.servlet-api</artifactId> 
<scope>provided</scope> 
</dependency> 

     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-data-rest</artifactId> 
     </dependency> 

     <!-- affirmed --> 
     <dependency>  
      <groupId>com.jcraft</groupId> 
      <artifactId>jsch</artifactId> 
      <version>0.1.53</version> 
     </dependency> 

     <dependency> 
      <groupId>org.postgresql</groupId> 
      <artifactId>postgresql</artifactId> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-websocket</artifactId> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-messaging</artifactId> 
     </dependency> 

    </dependencies> 

    <build> 
     <plugins> 
     <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-war-plugin</artifactId> 
       <configuration> 
       </configuration> 
      </plugin> 
      <plugin> 
       <artifactId>maven-clean-plugin</artifactId> 
       <configuration> 
        <filesets> 
         <fileset> 
          <directory>${frontend.target.dir}</directory> 
          <includes> 
           <include>**/*</include> 
          </includes> 

          <excludes> 
           <exclude>**/authentication/*</exclude> 
           <exclude>**/serviceability/**</exclude> 
          </excludes> 
         </fileset> 
        </filesets> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.springframework.boot</groupId> 
       <artifactId>spring-boot-maven-plugin</artifactId> 
       <configuration> 
        <layout>WAR</layout> 
        <executable>true</executable> 
        <mainClass>com.test.app.Application</mainClass> 
       </configuration> 
       <executions> 
        <execution> 
         <goals> 
          <goal>repackage</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 

     </plugins> 
    </build> 

</project> 

、私は次のエラーを取得する:

org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean. 
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE] 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:536) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE] 
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE] 
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE] 
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE] 
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE] 
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE] 
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE] 
    at com.test.proj.myapp.Application.main(Application.java:43) [classes/:na] 
Caused by: org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean. 
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getEmbeddedServletContainerFactory(EmbeddedWebApplicationContext.java:189) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE] 
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:162) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE] 
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE] 
    ... 8 common frames omitted 

私がしようとしました私はここでこのエラーを修正するために逃しているすべてのアイデア、それについての多くの異なる文書に従ってください?

+0

スプリングブートはサーブレットエンジンを直接組み込みます - どうしてWildflyでそれを使用する必要がありますか? Wildflyをパッケージ化する必要がある場合は、[Wildfly Swarm](http://wildfly-swarm.io/)をご覧ください。 – stdunbar

答えて

0

spring-boot-starter-tomcatは除外されているため、アプリケーションにはサーブレットコンテナが組み込まれていませんが、メインメソッドで実行しようとしています。むしろ組み込みTomcatを除くよりも、あなたはそれが提供する依存関係を持って宣言することができます:java -jar yourapp.warと実行の戦争として、それを実行している場合、アプリケーションのmainメソッドを実行している場合、またはこれは、それが利用できるようになります

<dependency> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-tomcat</artifactId> 
    <scope>provided</scope> 
</dependency> 

。ワイルドフライのような外部のコンテナに戦争を展開するときにクラスパス上にないように、warファイルにパッケージ化されています。

関連する問題