2017-04-07 2 views

答えて

0

あなたは依存関係の管理システムを使用する必要があります。

これは、SpringブートWARモジュールプロジェクトの親をspring-boot-starter-parentと異なるものに設定することを可能にします。そして、他のどのような同じようにEAR一つにWARプロジェクトを含めることが可能であろうです。

<dependencyManagement> 
    <dependencies> 
     <dependency> 
      <!-- Import dependency management from Spring Boot --> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-dependencies</artifactId> 
      <version>1.5.2.RELEASE</version> 
      <type>pom</type> 
      <scope>import</scope> 
     </dependency> 
    </dependencies> 
</dependencyManagement> 

...今、あなたは、通常の方法ですべての春ブーツスターターの依存関係を使用することができます。

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

あなたはモジュール・プロジェクト・レベルで指定することがきたスターターの依存関係は、依存関係の管理しながら、設定は、両方のアプリケーションで指定することができます。つまり、アプリケーションの要件に応じて、EAR個のプロジェクト全体または個々に個別に設定することができます。

Using Spring Boot without the parent POM

2

は、あなたの春のブートプロジェクトである戦争のプロジェクトが含まれる親プロジェクト、およびちょうどあなたの耳を作るための耳のプロジェクトが必要です。

親が親としてのスプリングブーツを持っている必要があります:

<?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> 

<parent> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-parent</artifactId> 
    <version>1.4.3.RELEASE</version> 
    </parent> 

    <groupId>com.greg</groupId> 
    <artifactId>ear-example</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>pom</packaging> 

    <properties> 
     <myproject.version>1.0-SNAPSHOT</myproject.version> 
    </properties> 

    <name>ear-example</name> 
    <modules> 
    <module>example-ear</module> 
    <module>example-war</module> 
    </modules> 

</project> 

EARプロジェクトは次のとおりです。

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

    <parent> 
    <groupId>com.greg</groupId> 
    <artifactId>ear-example</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    </parent> 

    <artifactId>example-ear</artifactId> 
    <packaging>ear</packaging> 

    <dependencies> 
    <dependency> 
     <groupId>com.greg</groupId> 
     <artifactId>example-war</artifactId> 
     <version>${project.version}</version> 
     <type>war</type> 
    </dependency> 
    </dependencies> 

    <build> 
    <plugins> 
    <plugin> 
     <artifactId>maven-ear-plugin</artifactId> 
     <version>2.10.1</version> 
     <configuration> 
       <modules> 
         <webModule> 
           <groupId>com.greg</groupId> 
           <artifactId>example-war</artifactId> 
           <contextRoot>/appname</contextRoot> 
         </webModule> 
       </modules> 
     </configuration> 
     </plugin> 
    </plugins> 
    </build> 

</project> 
関連する問題