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

多模块maven project intellij中的Spring Boot配置

郭兴平
2023-03-14

我在为我的多模块maven项目正确设置Spring Boot时遇到了一个问题。

    <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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>

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

  <groupId>parent</groupId>
  <artifactId>parent</artifactId>
    <!--The packaging is defined as ‘pom’ to tell maven not to package-->
  <packaging>pom</packaging>
  <version>1.0</version>
  <name>pfe Soliam Monitoring</name>

    <properties>
        <spring-boot.version>1.3.3.RELEASE</spring-boot.version>
    </properties>

  <modules>
    <module>core</module>
    <module>tierce</module>
  </modules>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <configuration>
            <source>1.7</source>
            <target>1.7</target>
          </configuration>
        </plugin>
      </plugins>
   </pluginManagement> 
  </build>

  <dependencies>

     <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

    <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>compile</scope>
        </dependency>

  </dependencies>
</project>
<?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>parent</groupId>
        <artifactId>parent</artifactId>
        <version>1.0</version>
    </parent>

    <groupId>core</groupId>
    <artifactId>core</artifactId>
    <version>1.0-SNAPSHOT</version>


    <properties>
        <java.version>1.7</java.version>

            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        </properties>




    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>1.3.3.RELEASE</version>
            </plugin>
        </plugins>
    </build>
    <dependencies>

        <dependency>
            <groupId>com.thetransactioncompany</groupId>
            <artifactId>cors-filter</artifactId>
            <version>2.5</version>
        </dependency>

        <dependency>
            <groupId>org.intrace</groupId>
            <artifactId>org.intrace</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <!--<dependency>-->
            <!--<groupId>com.oracle</groupId>-->
            <!--<artifactId>ojdbc6</artifactId>-->
            <!--<version>11.2.0.1.0</version>-->
        <!--</dependency>-->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>4.2.5.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>4.2.5.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.4</version>
        </dependency>
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.6</version>
        </dependency>


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

        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.2</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-rest</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-rest-hal-browser</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jersey</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.retry</groupId>
            <artifactId>spring-retry</artifactId>
        </dependency>

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


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

        <dependency>
            <groupId>org.jvnet.opendmk</groupId>
            <artifactId>jmxremote_optional</artifactId>
            <version>1.0_01-ea</version>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>2.7.2</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-amqp</artifactId>
        </dependency>
        <dependency>
            <groupId>jboss</groupId>
            <artifactId>jboss-jmx</artifactId>
            <version>4.2.2.GA</version>
        </dependency>

        <dependency>
            <groupId>org.apache.activemq</groupId>
            <artifactId>activemq-all</artifactId>
            <version>5.12.3</version>
        </dependency>
        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
            <version>2.11.0</version>
        </dependency>
        <dependency>
            <groupId>antlr</groupId>
            <artifactId>antlr</artifactId>
        </dependency>
        <dependency>
            <groupId>xalan</groupId>
            <artifactId>xalan</artifactId>
            <version>2.7.1</version>
        </dependency>

        <dependency>
            <groupId>org.jboss.spec.javax.ejb</groupId>
            <artifactId>jboss-ejb-api_3.1_spec</artifactId>
            <version>1.0.2.Final</version>
        </dependency>

        <!--<dependency>
            <groupId>org.jboss</groupId>
            <artifactId>jboss-remote-naming</artifactId>
            <version>2.0.4.Final</version>

        </dependency>-->

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

        <dependency>
            <groupId>org.neo4j</groupId>
            <artifactId>neo4j-cypher-compiler-2.2</artifactId>
            <version>2.2.5</version>
        </dependency>
    </dependencies>


</project>
<?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>tierce</groupId>
    <artifactId>tierce</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <properties>
        <java.version>1.7</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <parent>
        <groupId>parent</groupId>
        <artifactId>parent</artifactId>
        <version>1.0</version>
    </parent>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>


    <dependencies>

        <dependency>
            <groupId>asm</groupId>
            <artifactId>asm-debug-all</artifactId>
            <version>3.3</version>
        </dependency>

        <dependency>
            <groupId>com.goebl</groupId>
            <artifactId>david-webb</artifactId>
            <version>1.3.0</version>
        </dependency>

        <dependency>
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
            <version>2.4</version>
            <classifier>jdk15</classifier>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>compile</scope>
        </dependency>

    </dependencies>

</project>
 @SpringBootApplication
    @Component

    public class coreApplication {

        databaseConnectionImpl dbconn = new databaseConnectionImpl();

        public static void main(String[] args) throws Exception {

            SpringApplication.run(coreApplication.class, args);
        }

    }

共有1个答案

陈斌
2023-03-14

我首先猜测解决方案,但您是否试图利用核心内工件tierce中的功能?如果是这样,您仍然需要在您对核心的依赖项中声明该工件。或者,如果core是构建许多应用程序的基础,那么您可以将core包含到您的tierce项目中,并从那里启动应用程序。

仅仅拥有一个multi-maven模块并不影响类路径上依赖关系的公开方式。

 类似资料:
  • 我有一个基本的SpringBoot应用程序。使用Spring初始值设定项、嵌入式Tomcat、Thymeleaf模板引擎,并将包作为可执行的JAR文件。是一个带有Spring Boot的多模块项目,该项目将有3个模块。这里是父模块pom。xml 这里是模块核心 这里是模块web: 从父根目录,我使用以下方法生成所有模块: 但问题是tdk-web-0.0.2-SNAPSHOT。jar不包含tdk-c

  • 父项目为demo-mybatis子模块为mybatis-dao、demo-service。demo-mybatis pom.xml如下: 4.0.0 pom mybatis-DAO Demo-service Demo-mybatis-app org.springframework.Boot spring-boot-starter-parent 2.3.2.release com.example D

  • 我有一个带有myapp-core和myapp-web模块的myapp父pom类型maven项目。myapp-core模块作为依赖项添加到MyApp-Web。 myapp-core模块中的所有类都位于根包com.myapp.core中,而myapp-web模块中的所有类都位于根包com.myapp.web中 主要的application.java也在com.myapp.web包中。由于我的核心模块根

  • springboot多模块项目中,vo,dto应该放在那一层比较合适? 如题,假设项目有如下包 demo-web demo-service demo-dao demo-common vo,dto应该放在那一层比较合适? dao层放mapper和DO(也就是和数据库表对应的类) 是毋庸置疑的。 VO我的理解是返回给前端页面的对象,按理说应该放在web模块比较合适,但是有时候我们可以在dao层直接写个

  • 我有一个问题,为我的多模块maven项目正确设置Spring启动。 有一个模块“api”使用另一个模块“core”。Api有一个应用程序。包含spring的属性文件。邮政主机=xxx。根据Spring Boot文档,这为您提供了JavaMailSender接口的默认实现,可以自动连接。 然而,负责发送电子邮件的类驻留在“核心”包中。当我尝试构建该模块时,构建失败,因为找不到JavaMailSend

  • 回到历史 我有这个android库,开发人员可以正常使用 现在我们正在从头开始重写库以创建V3。 在这个重组中,我们设法将lib分解成模块。所以可以说在V3上我们会有以下文物 这将为gradle结构提供以下模块: 对于其提供了一个,这样就可以使用模块中的所有内容,但实际上不需要在内部编译它。 但是我也想为现有的主机应用程序提供一个简单的迁移路径。意思是,我希望在V3上也有以下结合了和的工件(这基本