当前位置: 首页 > 知识库问答 >
问题:

带有自定义父级的Spring Boot应用程序模块-让它工作

缑永年
2023-03-14

目标:获得与spring-boot-starter-parent完美工作的Spring Boot应用程序模块,与我们自己的自定义父POM一起工作。我正在遵循这一指南,很抱歉地说,我不能让这充分发挥作用。https://www.surasint.com/spring-boot-with-no-parent-example/。

具体地说,使用spring-boot-starter作为父pom时,一切都很好。

有了我们自己的父pom,Spring Boot应用程序就坏了。

我有一个项目设置与三个模块和我自己的父POM。有很多原因需要这样做(父pom使用Maven概要文件,并根据这些概要文件设置重要的数据库变量)。

    null

我使用的是Spring Boot1.5.9、Maven3.3和Java8.
理论上我完全同意它应该在没有spring-boot-starter-parent的情况下工作。然而,当使Spring Boot模块只继承父pom而不继承spring-boot-starter-parent时,会出现以下异常(对我来说非常奇怪)。

  2018-02-07 16:06:46.822 ERROR 10008 --- [           main] 
    o.s.boot.SpringApplication               : Application startup failed                  

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerAdapter' defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]: Factory method 'requestMappingHandlerAdapter' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcValidator' defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.validation.Validator]: Factory method 'mvcValidator' threw exception; nested exception is java.lang.NoSuchMethodError: org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration.getApplicationContext()Lorg/springframework/context/ApplicationContext; 

        at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE] 

        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE] 

该项目在IntelliJ中是完全绿色的,编译正常。只有在启动Spring Boot应用程序时才会出现这些错误。正如我所解释的,Spring boot应用程序模块现在缺少了以前的一些东西。这里的任何建议都是最有帮助的!

具体来说,您需要导入什么(在Maven dependency-tags中)以使模块能够访问与它从spring-boot-starter-parent而不是您自己的自定义父级继承时完全相同的东西和所有东西?如果不是通过纯粹的直觉来猜测您的依赖关系(这在我的情况下显然是失败的),而是有一个引用依赖关系检查列表来确保您的模块可以访问完全相同的内容,就像直接从spring-boot-starter-parent继承一样,那就太棒了。

到目前为止,我纯粹凭直觉在Spring Boot模块中添加了以下内容(上面称为“Web”)

<!-- === [Spring Boot Starter] === --> 
<dependency> 
  <groupId>org.springframework.boot</groupId> 
  <artifactId>spring-boot-starter</artifactId> 
</dependency> 
<dependency> 
  <groupId>org.springframework.boot</groupId> 
  <artifactId>spring-boot-starter-test</artifactId> 
  <scope>test</scope> 
</dependency> 
<dependency> 
  <groupId>org.springframework.boot</groupId> 
  <artifactId>spring-boot-starter-web</artifactId> 
</dependency> 

很明显,缺少了spring-boot-starter作为父级所存在的一些东西。而且,奇怪的是,其余可能的spring-boot-starter依赖项似乎与项目完全无关(比如云连接器、Twitter连接器、mongodb和相关)。我添加了所有远程相关只是为了测试,但下面的错误仍然存在。任何建议或帮助都是非常感谢的。

作为参考,这里是父POM:

<?xml version="1.0" encoding="UTF-8"?>
<!-- parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.2.RELEASE</version>
</parent -->

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.source.encoding>UTF-8</project.source.encoding>
    <project.source.version>1.8</project.source.version>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>

    <spring.boot.version>1.5.9.RELEASE</spring.boot.version>
    <failOnMissingWebXml>false</failOnMissingWebXml>
</properties>

<dependencyManagement>
    <dependencies>
        <!--
            Import dependency management from Spring Boot
            * This fixes the Spring boot parent issue [inherit dependencyManagement without forcing Spring Boot App]
            * It does NOT include the plugin management
            See https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-build-systems.html#using-boot-maven-without-a-parent
            See http://www.logicbig.com/tutorials/spring-framework/spring-boot/starter-import/
         -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>${spring.boot.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            <version>${spring.boot.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <version>${spring.boot.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>${spring.boot.version}</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa -->
        <!-- === [Spring Boot JPA] ===-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
            <version>${spring.boot.version}</version>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>1.4.196</version>
        </dependency>
        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc7</artifactId>
            <version>12.1.0.1</version>
        </dependency>
        <!-- === [Spring Boot Security] ===-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
            <version>${spring.boot.version}</version>
        </dependency>

        <!-- === [Spring Boot Maven plugin needed for profile management] ===-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>${spring.boot.version}</version>
        </dependency>

        <!-- === [Messaging] ===-->
        <!--
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-activemq</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.activemq</groupId>
            <artifactId>activemq-broker</artifactId>
        </dependency>
        -->
        <dependency>
            <groupId>org.springframework.amqp</groupId>
            <artifactId>spring-rabbit</artifactId>
            <version>1.7.2.RELEASE</version>
        </dependency>

        <!-- ===[Messaging with AMQP over JMS with the Apache QPID client] === -->
        <dependency>
            <groupId>org.apache.qpid</groupId>
            <artifactId>qpid-jms-client</artifactId>
            <version>0.24.0</version>
        </dependency>
        <!-- === [Date and Time management] ===-->
        <dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-jsr310</artifactId>
            <version>2.9.4</version>
        </dependency>

        <!-- === [XStream for converting classes to and from XML] === -->
        <!-- NB!
        XStream also needs Apache's commons-io
        2017.10.15: The artifact org.apache.commons:commons-io:jar:1.3.2 has been relocated to commons-io:commons-io:jar:1.3.2
        See https://mvnrepository.com/artifact/org.apache.commons/commons-io
        See https://mvnrepository.com/artifact/commons-io/commons-io
        -->
        <dependency>
            <groupId>com.thoughtworks.xstream</groupId>
            <artifactId>xstream</artifactId>
            <version>1.4.10</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>1.3.2</version>
        </dependency>

        <!-- === [Spring MVC and WEB (javax.servlet, JSP/JSTL] === -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>4.1.5.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>taglibs</groupId>
            <artifactId>standard</artifactId>
            <version>1.1.2</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

        <!-- === [Logging and Testing] === -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.25</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.7.25</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>

    </dependencies>
</dependencyManagement>

<profiles>
    <profile>
        <id>dev</id>
        <properties>
            <activatedProperties>dev</activatedProperties>
            <datasourceURL>jdbc:oracle:thin:@h1-a-oradb10t:1521:fasitngft1</datasourceURL>
            <datasourceUser>fasithub</datasourceUser>
            <datasourcePassword>cH9nIiBzuS5Ho3q1bOP5</datasourcePassword>
            <datasourceDriver>oracle.jdbc.OracleDriver</datasourceDriver>
            <ecpServer>amqp://ec2-52-34-81-131.us-west-2.compute.amazonaws.com:5672</ecpServer>
            <ecpServerSolnett>amqp://ec2-52-40-134-91.us-west-2.compute.amazonaws.com:5672</ecpServerSolnett>
            <ecpServerVindnett>amqp://ec2-34-213-80-66.us-west-2.compute.amazonaws.com:5672</ecpServerVindnett>
            <ecpEndpointSuffix></ecpEndpointSuffix>
        </properties>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
    </profile>
    <profile>
        <id>test</id>
        <properties>
            <activatedProperties>test</activatedProperties>
            <datasourceURL>jdbc:h2:file:~/test</datasourceURL>
            <datasourceUser>sa</datasourceUser>
            <datasourcePassword></datasourcePassword>
            <datasourceDriver>org.h2.Driver</datasourceDriver>
            <ecpServer>amqp://ec2-52-34-81-131.us-west-2.compute.amazonaws.com:5672</ecpServer>
            <ecpServerSolnett>amqp://ec2-52-40-134-91.us-west-2.compute.amazonaws.com:5672</ecpServerSolnett>
            <ecpServerVindnett>amqp://ec2-34-213-80-66.us-west-2.compute.amazonaws.com:5672</ecpServerVindnett>
            <ecpEndpointSuffix></ecpEndpointSuffix>
        </properties>
    </profile>
    <profile>
        <id>staging</id>
        <properties>
            <activatedProperties>staging</activatedProperties>
            <datasourceURL>jdbc:oracle:thin:@h1-a-oradb10t:1521:fasitngft1</datasourceURL>
            <datasourceUser>fasithub</datasourceUser>
            <datasourcePassword>cH9nIiBzuS5Ho3q1bOP5</datasourcePassword>
            <datasourceDriver>oracle.jdbc.OracleDriver</datasourceDriver>
            <ecpServer>amqp://h1-a-ecp4end:6672</ecpServer>
            <ecpServerSolnett>amqp://ec2-52-40-134-91.us-west-2.compute.amazonaws.com:5672</ecpServerSolnett>
            <ecpServerVindnett>amqp://ec2-34-213-80-66.us-west-2.compute.amazonaws.com:5672</ecpServerVindnett>
            <ecpEndpointSuffix>FASIT-SERVICE</ecpEndpointSuffix>
        </properties>
    </profile>
</profiles>

这里是spring boot应用程序模块pom(这里是当前出现试错的地方):

<?xml version="1.0" encoding="UTF-8"?>

http://maven.apache.org/xsd/maven-4.0.0.xsd“>4.0.0

<!-- Alt.1: have our own parent: this is the way to go for a common jar module.
    ISSUE: Spring Boot module fails to run - applicationContext fails to load!
    Solution: explicitly define goal for spring-boot-maven-plugin (If you use Spring Boot as parent, you do not have to explicitly define this)
-->
<parent>
    <groupId>no.statnett.fasit</groupId>
    <artifactId>fasit-hub-backend</artifactId>
    <version>1.0-SNAPSHOT</version>
</parent>

<!-- Alt.2: have spring-boot-starter-parent as parent. This is useful for a Spring Boot app module.
    ISSUE: profile management breaks - properties are not set on the Spring Boot module!
    Solution: not possible without our own parent pom
-->
<!-- parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
<relativePath/>
</parent -->

<!-- Spring Boot starter properties overrule (default Java is only 1.6) -->
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.8</java.version>
    <!-- spring.boot.version>1.5.6.RELEASE</spring.boot.version -->
</properties>

<groupId>no.statnett.fasit</groupId>
<artifactId>web</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<!-- === [Dependency Management] === -->
<dependencies>
    <dependency>
        <groupId>no.statnett.fasit</groupId>
        <artifactId>common</artifactId>
        <version>${project.version}</version>
    </dependency>

    <!-- === [Spring Boot Starter] === -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web-services</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-validation</artifactId>
    </dependency>
    <!-- Following three dependencies where not needed with spring-boot-starter-parent as parent:
     spring-boot-starter-tomcat, spring-boot-starter-thymeleaf, spring-boot-starter-data-rest
     STILL GET ISSUE:
     Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate
        [org.springframework.data.rest.core.config.RepositoryRestConfiguration]:
        Factory method 'config' threw exception; nested exception is java.lang.NoClassDefFoundError:
        org/springframework/data/rest/core/config/RepositoryCorsRegistry
    -->

    <!-- === [Spring Boot JPA] === -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.javassist</groupId>
                <artifactId>javassist</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <!-- === [Oracle driver official, manually installed] ===-->
    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc6</artifactId>
        <version>11.2.0.3.0</version>
        <type>pom</type>
    </dependency>

    <!-- === [Spring Boot Security] ===-->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>

    <!-- === [Date and Time management] ===-->
    <dependency>
        <groupId>com.fasterxml.jackson.datatype</groupId>
        <artifactId>jackson-datatype-jsr310</artifactId>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.8.3</version>
    </dependency>

    <!-- === [XStream for converting classes to and from XML] === -->
    <!-- NB! moved to the common module, they are not needed here in the web service module! -->
</dependencies>

<!-- === [Build management for the Spring Boot module] === -->
<build>
    <plugins>
        <!-- === [Spring Boot Maven plugin is used for profile management] ===-->
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>${spring.boot.version}</version>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <!-- === [Apache Maven compiler plugin for building] ===-->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <configuration>
                <source>${java.version}</source>
                <target>${java.version}</target>
            </configuration>
        </plugin>
    </plugins>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
    </resources>
</build>

Upadte1:如果我将以下三个依赖项添加到spring app模块POM中:

        <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-validation</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-rest</artifactId>
    </dependency>
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.rest.core.config.RepositoryRestConfiguration]: Factory method 'config' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/data/rest/core/config/RepositoryCorsRegistry
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE]
... 144 common frames omitted

原因:java.lang.noClassDefFounderRorr:org/springframework/data/rest/core/config/repositoryCorsRegistry

我不知道如何解释这一点。这是否意味着我们在正确的轨道上,只需要添加一些额外的depedency,或者依赖项不必要地添加,可能会导致不必要的问题?

现在缺少的类是https://docs.Spring.io/Spring-data/rest/docs/current/api/org/springframework/data/rest/core/config/repositorycorsregistry.html,我不确定应该添加什么作为依赖项,以便在Spring boot中以正确的方式访问这个类。当然,我不愿意通过普通的spring framework依赖项(如https://mvnrepository.com/artifact/org.springframework/spring-web/5.0.3.release)添加它,因为这通常会导致版本问题(spring Boot包括相关的springframeworkd,应该完全通过spring Boot来管理,据我所知,我已经被告知过很多次了)。

更新2:也许不符合更好的判断--而且因为我愿意测试任何东西,直到一切正常工作--我添加了下面的库,这些库中有当前缺少的类。

当然,只有在仔细检查https://mvnrepository.com/artifact/org.springframework.Boot/spring-boot/1.5.9.release以确定Spring Boot版本使用的核心org.springframework库之后,才能完成此操作。

 <dependency> 
<groupId>org.springframework</groupId> 
<artifactId>spring-core</artifactId> 
<version>4.3.13.RELEASE</version> 
</dependency> 
<dependency> 
<groupId>org.springframework</groupId> 
<artifactId>spring-context</artifactId> 
<version>4.3.13.RELEASE</version> 
</dependency> 
<dependency> 
<groupId>org.springframework</groupId> 
<artifactId>spring-web</artifactId> 
<version>4.3.13.RELEASE</version> 
</dependency> 

我现在得到了一个不同的例外:

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.web.filter.OrderedHttpPutFormContentFilter]: Factory method 'httpPutFormContentFilter' threw exception; nested exception is java.lang.NoClassDefFoundError: Could not initialize class com.fasterxml.jackson.databind.ObjectMapper 

    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE] 

    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE] 

    ... 26 common frames omitted 

Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.fasterxml.jackson.databind.ObjectMapper 

    at org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.build(Jackson2ObjectMapperBuilder.java:588) ~[spring-web-4.3.13.RELEASE.jar:4.3.13.RELEASE]

这导致我添加了以下依赖项(再次仔细检查了上面的Spring Boot引用,以查看它使用的特定库的版本):

<dependency> 
<groupId>com.fasterxml.jackson.core</groupId> 
<artifactId>jackson-databind</artifactId> 
<version>2.9.4</version> 
</dependency> 

然而,可悲和奇怪的是--同样的例外仍然存在。这意味着我们陷入了死胡同,因为https://mvnrepository.com/artifact/org.springframework.boot/spring-boot/1.5.9.release中没有更多的逻辑库可以包含。

所以让我们退一步,看看我们需要什么。

  • Spring Boot app模块包含一组REST服务。
  • 其中一组服务只提供GET请求,并生成application/xml(用于与alpha类型的系统集成)
  • 另一组服务生成和使用application/json(用于与欧米茄类型的系统集成)。

就是这样。所有核心服务和JPA逻辑都在公共库模块中,这是web Spring Boot app模块和worker模块所需要的。

干杯!

共有1个答案

邵亦
2023-03-14

Spring Boot Starter父级不能成为父级POM的父级是不是有什么原因?我看到它在您的自定义父级中被注释掉了。

此设置应该可以工作:

自定义父级pom

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

<!-- All of your customizations follow -->
<dependencies>
    <!-- Define common dependencies for all child modules-->
</dependencies>

<dependencyManagement>
    <!-- Define optional module dependencies with preferred versions -->
    <!-- This can help the module developers to not have to deal with dependency conflicts if you handle them here -->
</dependencyManagement>

<build>
    <plugins>
        <!-- Define common plugin configs for all child modules -->
    </plugins>

    <pluginManagement>
        <plugins>
            <!-- Define optional plugin configs for child modules -->
        </plugins>
    </pluginManagement>
</build>
<parent>
    <groupId>no.statnett.fasit</groupId>
    <artifactId>fasit-hub-backend</artifactId>
    <version>1.0-SNAPSHOT</version>
</parent>

老实说,应该就是这样。然后您创建了一个自定义父pom,它从Spring Boot Starter父级中正确地继承了所有内容,并且您可以提供所有您自己的配置文件和其他您希望应用程序模块继承的自定义。

您应该不必经历重新创建Spring Boot应用程序的依赖关系树的所有麻烦,正如您所注意到的,这样做基本上是依赖关系管理的地狱般的场景。

 类似资料:
  • 我读了很多关于如何在spring boot项目中使用spring-boot-starter-parent的帖子。基本上,我读过一些帖子(Spring文档也讨论了这一点),这些帖子描述了两种实现这一点的方法 直接使用spring-boot-starter-parent作为项目父级。它给我们带来了依赖管理和插件管理的好处。 另一种方法是在项目pom中导入spring-boot-starter父级(如果

  • 我正在寻找Spring Boot maven应用程序的工作示例,没有引用spring-boot-starter-parent作为父POM。 我在Spring Boot docs-http://Docs.Spring.io/spring-boot/Docs/1.0.1.release/reference/htmlsingle/#using-boot-maven-your-own-parent中找到了

  • 当尝试运行或调试带有applicationIdSuffix(.debug)的自定义BuildType时,手机上安装了应用程序,但正确的活动实际上并没有启动。实际上,启动了具有原始包名的活动(示例:在应该启动com.fobbymaster.app.debug时启动了com.fobbymaster.app)。 我在想,有一些配置需要修改,但我似乎找不到。 有什么想法吗? 设备SHELL命令:pm in

  • 我正在寻找关于如何建立一个谷歌应用引擎项目的建议,该项目涉及多个模块,其中一个模块是GWT项目。我已经阅读了谷歌应用引擎模块文档(https://developers.google.com/appengine/docs/java/modules/)并在Stackoverflow上找到了一些帮助,比如本文使用appengine骨架原型发布GWT GAE应用程序引擎模块。然而,这涉及到很多东西,所以我

  • 有人能帮我解决我遇到的自定义Prestashop模块1.6版本的文件路径问题吗? 以下内容在本地主机环境中非常有效: 但是不能在实时服务器上工作。以下方法确实有效: 这是不可接受的,因为有些客户不会使用默认的引导主题。 对此问题的任何帮助都将不胜感激。 谢谢

  • 我正在开发一个React应用程序,我想测试一个模块,我们称之为B,这取决于另一个模块,我们称之为a。 场景可能是这样的: 测试我的组件的核心库是Jest和Ezyme。我的目标是测试模块B,但我想单独测试它,所以我想模拟对模块A的依赖。js。 我知道一种方法是注入helperFn作为道具,而不是导入它,这样在测试期间我就可以注入一个模拟函数,但是这个应用程序上有很大的模块,每个模块都有一些依赖关系。