精华内容
下载资源
问答
  • I've got a multi module project: The parent POM.xml:xmlns:xsi=...

    I've got a multi module project: The parent POM.xml:

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

    4.0.0

    org.springframework.boot

    spring-boot-starter-parent

    1.4.3.RELEASE

    be.bodyreset

    bodyreset-parent

    1.0.0-SNAPSHOT

    pom

    Bodyreset Parent

    Manages the common properties and dependencies for the child modules

    bodyreset-commons

    messaging-contract

    discovery-microservice

    api-gateway-microservice

    rest-client-microservice

    email-commons

    security-microservice

    user-microservice

    point-of-service-microservice

    bodyreset

    1.8

    1.6.6

    ...

    com.spotify

    docker-maven-plugin

    0.4.11

    org.apache.maven.plugins

    maven-compiler-plugin

    3.6.0

    ${java.version}

    ${java.version}

    org.apache.maven.plugins

    maven-jar-plugin

    3.0.2

    The POM.xml of the rest-client-microservice looks like this:

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

    4.0.0

    be.bodyreset

    bodyreset-parent

    1.0.0-SNAPSHOT

    rest-client-microservice

    1.0.0-SNAPSHOT

    jar

    Rest Client Microservice

    Manages the REST clients to use for inter-service communication

    org.apache.commons

    commons-lang3

    org.projectlombok

    lombok

    org.springframework.boot

    spring-boot-starter-web

    org.springframework.boot

    spring-boot-starter-hateoas

    org.springframework.boot

    spring-boot-starter-test

    test

    org.springframework.cloud

    spring-cloud-starter-eureka

    org.springframework.cloud

    spring-cloud-starter-feign

    org.springframework.cloud

    spring-cloud-starter-hystrix

    com.spotify

    docker-maven-plugin

    package

    build

    ${docker.image.prefix}/${project.artifactId}

    ${project.basedir}/src/main/docker

    /

    ${project.build.directory}

    ${project.build.finalName}.jar

    org.apache.maven.plugins

    maven-jar-plugin

    test-jar

    org.springframework.boot

    spring-boot-maven-plugin

    repackage

    The POM.xml of the email-commons module looks as follows:

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

    4.0.0

    be.bodyreset

    bodyreset-parent

    1.0.0-SNAPSHOT

    email-commons

    1.0.0-SNAPSHOT

    jar

    Email Commons

    Enables sending emails via SMPT

    be.bodyreset

    rest-client-microservice

    1.0.0-SNAPSHOT

    be.bodyreset

    rest-client-microservice

    1.0.0-SNAPSHOT

    test-jar

    test

    org.apache.commons

    commons-lang3

    org.projectlombok

    lombok

    org.powermock

    powermock-api-mockito

    test

    org.powermock

    powermock-module-junit4

    test

    org.springframework.boot

    spring-boot-starter-mail

    org.springframework.boot

    spring-boot-starter-thymeleaf

    org.springframework.boot

    spring-boot-starter-test

    test

    org.apache.maven.plugins

    maven-jar-plugin

    test-jar

    If I try to perform a maven clean install on the parent project, I get the following result:

    [INFO] ------------------------------------------------------------------------

    [INFO] Building Email Commons 1.0.0-SNAPSHOT

    [INFO] ------------------------------------------------------------------------

    [INFO]

    [INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) @ email-commons ---

    [INFO] Deleting /home/developer/ideaProjects/bodyreset/email-commons/target

    [INFO]

    [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ email-commons ---

    [INFO] Using 'UTF-8' encoding to copy filtered resources.

    [INFO] Copying 0 resource

    [INFO] Copying 2 resources

    [INFO]

    [INFO] --- maven-compiler-plugin:3.6.0:compile (default-compile) @ email-commons ---

    [INFO] Changes detected - recompiling the module!

    [INFO] Compiling 17 source files to /home/developer/ideaProjects/bodyreset/email-commons/target/classes

    [INFO] -------------------------------------------------------------

    [ERROR] COMPILATION ERROR :

    [INFO] -------------------------------------------------------------

    [ERROR] /home/developer/ideaProjects/bodyreset/email-commons/src/main/java/be/bodyreset/mail/converter/UserDTOToRecipientConverter.java:[4,29] package be.bodyreset.rest.dto does not exist

    [ERROR] /home/developer/ideaProjects/bodyreset/email-commons/src/main/java/be/bodyreset/mail/converter/UserDTOToRecipientConverter.java:[16,63] cannot find symbol

    symbol: class UserDTO

    [ERROR] /home/developer/ideaProjects/bodyreset/email-commons/src/main/java/be/bodyreset/mail/converter/UserDTOToRecipientConverter.java:[22,30] cannot find symbol

    symbol: class UserDTO

    location: class be.bodyreset.mail.converter.UserDTOToRecipientConverter

    [ERROR] /home/developer/ideaProjects/bodyreset/email-commons/src/main/java/be/bodyreset/mail/converter/UserDTOToSenderConverter.java:[4,29] package be.bodyreset.rest.dto does not exist

    [ERROR] /home/developer/ideaProjects/bodyreset/email-commons/src/main/java/be/bodyreset/mail/converter/UserDTOToSenderConverter.java:[5,29] package be.bodyreset.rest.dto does not exist

    [ERROR] /home/developer/ideaProjects/bodyreset/email-commons/src/main/java/be/bodyreset/mail/converter/UserDTOToSenderConverter.java:[15,60] cannot find symbol

    symbol: class UserDTO

    [ERROR] /home/developer/ideaProjects/bodyreset/email-commons/src/main/java/be/bodyreset/mail/converter/UserDTOToSenderConverter.java:[21,27] cannot find symbol

    symbol: class UserDTO

    location: class be.bodyreset.mail.converter.UserDTOToSenderConverter

    [ERROR] /home/developer/ideaProjects/bodyreset/email-commons/src/main/java/be/bodyreset/mail/service/impl/SenderServiceImpl.java:[7,32] package be.bodyreset.rest.client does not exist

    [ERROR] /home/developer/ideaProjects/bodyreset/email-commons/src/main/java/be/bodyreset/mail/service/impl/SenderServiceImpl.java:[8,32] package be.bodyreset.rest.client does not exist

    [ERROR] /home/developer/ideaProjects/bodyreset/email-commons/src/main/java/be/bodyreset/mail/service/impl/SenderServiceImpl.java:[9,29] package be.bodyreset.rest.dto does not exist

    [ERROR] /home/developer/ideaProjects/bodyreset/email-commons/src/main/java/be/bodyreset/mail/service/impl/SenderServiceImpl.java:[10,29] package be.bodyreset.rest.dto does not exist

    [ERROR] /home/developer/ideaProjects/bodyreset/email-commons/src/main/java/be/bodyreset/mail/service/impl/SenderServiceImpl.java:[34,13] cannot find symbol

    symbol: class PointOfServiceClient

    location: class be.bodyreset.mail.service.impl.SenderServiceImpl

    [ERROR] /home/developer/ideaProjects/bodyreset/email-commons/src/main/java/be/bodyreset/mail/service/impl/SenderServiceImpl.java:[37,13] cannot find symbol

    symbol: class UserClient

    location: class be.bodyreset.mail.service.impl.SenderServiceImpl

    [ERROR] /home/developer/ideaProjects/bodyreset/email-commons/src/main/java/be/bodyreset/mail/service/impl/SenderServiceImpl.java:[63,13] cannot find symbol

    symbol: class PointOfServiceDTO

    location: class be.bodyreset.mail.service.impl.SenderServiceImpl

    [ERROR] /home/developer/ideaProjects/bodyreset/email-commons/src/main/java/be/bodyreset/mail/service/impl/RecipientServiceImpl.java:[7,32] package be.bodyreset.rest.client does not exist

    [ERROR] /home/developer/ideaProjects/bodyreset/email-commons/src/main/java/be/bodyreset/mail/service/impl/RecipientServiceImpl.java:[8,29] package be.bodyreset.rest.dto does not exist

    [ERROR] /home/developer/ideaProjects/bodyreset/email-commons/src/main/java/be/bodyreset/mail/service/impl/RecipientServiceImpl.java:[32,13] cannot find symbol

    symbol: class UserClient

    location: class be.bodyreset.mail.service.impl.RecipientServiceImpl

    [INFO] 17 errors

    [INFO] -------------------------------------------------------------

    [INFO] ------------------------------------------------------------------------

    [INFO] Reactor Summary:

    [INFO]

    [INFO] Bodyreset Parent .................................. SUCCESS [0.690s]

    [INFO] Bodyreset Commons ................................. SUCCESS [7.444s]

    [INFO] Messaging Contract ................................ SUCCESS [1.751s]

    [INFO] Discovery Microservice ............................ SUCCESS [19.925s]

    [INFO] API Gateway Microservice .......................... SUCCESS [17.272s]

    [INFO] Rest Client Microservice .......................... SUCCESS [15.271s]

    [INFO] Email Commons ..................................... FAILURE [1.026s]

    [INFO] Security Microservice ............................. SKIPPED

    [INFO] User Microservice ................................. SKIPPED

    [INFO] Point Of Service Microservice ..................... SKIPPED

    [INFO] ------------------------------------------------------------------------

    [INFO] BUILD FAILURE

    [INFO] ------------------------------------------------------------------------

    [INFO] Total time: 1:04.292s

    [INFO] Finished at: Thu Jan 19 11:53:25 CET 2017

    [INFO] Final Memory: 63M/656M

    [INFO] ------------------------------------------------------------------------

    I've been breaking my head on this issue for several days now, but I don't have a clue why this isn't working.

    解决方案

    I figured it out. The rest-client-microservice is a Spring Boot project and uses the following plugin:

    org.springframework.boot

    spring-boot-maven-plugin

    repackage

    The jar is repackaged and all the packages and classes are put in the BOOT-INF folder. That's the reason why Maven is unable to find them. You can fix this by defining the plugin like this:

    org.springframework.boot

    spring-boot-maven-plugin

    repackage

    exec

    With this configuration, the Spring Boot Maven Plugin will create 2 JARs: the main one will be the same as a usual Maven project, while the second one will have the classifier appended and be the executable JAR.

    展开全文
  • 其中common下的为普通的Maven模块,service下的为需要SpringBoot发布的模块 common-base依赖 common-util,service依赖common-base 附上依赖的配置 以common-base模块依赖 common-util模块为例 common-util的p

    针对多模块的项目存在的依赖问题

    例如

    • Parent父模块
      • common
        • common-util
        • common-base
      • service
        • service-cms
        • service-oss

    其中common下的包为普通的Maven模块,service下的包为需要SpringBoot发布的模块
    common-base依赖 common-util,service依赖common-base

    附上依赖的配置

    以common-base模块依赖 common-util模块为例
    common-util的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">
        <parent>
            <artifactId>common</artifactId>
            <groupId>com.ymz</groupId>
            <version>0.0.1-SNAPSHOT</version>
        </parent>
        <modelVersion>4.0.0</modelVersion>
    
        <artifactId>common-util</artifactId>
        
    </project>
    

    common-base的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">
        <parent>
            <artifactId>common</artifactId>
            <groupId>com.ymz</groupId>
            <version>0.0.1-SNAPSHOT</version>
        </parent>
        <modelVersion>4.0.0</modelVersion>
    
        <artifactId>service-base</artifactId>
    	<!--添加依赖-->
        <dependencies>
            <dependency>
                <groupId>com.ymz</groupId>
                <artifactId>common-util</artifactId>
                <version>0.0.1-SNAPSHOT</version>
            </dependency>
        </dependencies>
    </project>
    

    Idea项目依赖的添加
    在Idea中打开Project Structure ==> Modules ==>common-base
    ==> Dependencies
    如图所示
    在这里插入图片描述

    存在问题:

    当使用Maven对common-util打完包之后,对 common-base项目直接进行package时,会显示找不到依赖( common-util中的类 )

    问题的原因

    spring-boot-maven-plugin插件,开发中在根项目的pom.xml文件中添加了spring-boot-maven-plugin插件,导致子项目出现问题.

    	<build>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
            </plugins>
        </build>
    

    解决办法

    将根项目中的spring-boot-maven-plugin插件注释掉,在真正需要的项目中添加,如service模块中

    最后

    如果还是出现上述问题,可以将依次重新打包,多考虑一下依赖的继承问题.

    参考

    关于maven项目多模块的打包问题的血泪经历
    IDEA maven 多模块打包问题总结

    展开全文
  • parent项目install一下。

    将parent项目install一下。

    展开全文
  • 因为之前用到的是,基于springboot框架所搭建的maven工程,而且都是相互独立的。现研发经理要求将所有工程进行整合和规范化,所以抽出一个parent父工程,base基础模块(包含一些公用的实体类和工具类等),以及其他子模块...

    场景:

    因为之前用到的是,基于springboot框架所搭建的maven工程,而且都是相互独立的。现研发经理要求将所有工程进行整合和规范化,所以抽出一个parent父工程,base基础模块(包含一些公用的实体类和工具类等),以及其他子模块(Module A、 Module B ...)。Module A 以及Module B工程都需要依赖base工程

    问题:

    在对Module A进行打包时,出现问题:Module A中所依赖的base工程的util程序包不存在。即使能打包成功,用java -jar启动jar包也会报Class Not Found,依赖的base工程的类找不到。

    解决方案:

    未解决之前在base工程的pom.xml中maven插件的配置如下:

        <build>  
            <plugins>  
                <plugin>  
                    <groupId>org.springframework.boot</groupId>  
                    <artifactId>spring-boot-maven-plugin</artifactId>  
                </plugin>  
            </plugins>  
        </build>  

    解决base工程的pom.xml的maven配置如下:

        <build>  
            <plugins>  
                <plugin>  
                    <groupId>org.springframework.boot</groupId>  
                    <artifactId>spring-boot-maven-plugin</artifactId>  
                    <configuration>  
                        <classifier>exec</classifier>  
                    </configuration>  
                </plugin>  
            </plugins>  
        </build>  

    原因分析:

    spring-boot-maven-plugin打包出来的jar是不可依赖的

     我们现在整合后的maven项目有一个parent工程,打包类型为pom,下面多个spring-boot工程作为它的module,分别为base和moduleA,moduleB。假如moduleA依赖于base。如果你在base中使用了spring-boot-maven-plugin的默认配置build,或者在parent工程中使用spring-boot-maven-plugin的默认配置build。那么在clean package的时候会发现moduleA找不到base中的类。原因就是默认打包出来的jar是不可依赖的。

    解决方案:

            官方告诉我们,你如果不想移代码,好吧,我这样来给你解决,给你打两个jar包,一个用来直接执行,一个用来依赖。于是,你需要指定一个属性classifier,这个属性为可执行jar包的名字后缀。比如我设置<classifier>exec</classifier>,原项目名为Vehicle-business。那么会得到两个jar:Vehicle-business.jar和Vehicle-bussiness-exec.jar

             官方文档位置:84.5 Use a Spring Boot application as a dependency

             总结:回到聚合maven上,如果你在parent工程中使用了spring-boot-maven-plugin作为builder,那么你的依赖module一定要用解决方案二来设置。否则你不在parent工程中用spring-boot-maven-plugin作为builder,而在需要打包的module上使用。

    一般parent工程的maven插件配置如下:

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                 <configuration>
              		<source>1.8</source>
              		<target>1.8</target>
            	</configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    被依赖的maven子模块的maven插件配置如下(其余maven子模块就不需要配置):

     <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <classifier>exec</classifier>
                </configuration>
            </plugin>
        </plugins>
    </build>
    

    其他的坑:

    1.jdk8一定要指明

             不指明的话在开发工具里运行没有一点问题,如果你没有用到java8的特性打包也没有问题。一旦你用到了java8的特性,而且使用spring-boot-maven-plugin作为builder,一定要指明jdk版本。不然你会收到类似不识别Lambda,请使用resource8这样的错误。

    <properties>
        <java.version>1.8</java.version>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
      </properties>

    2.BOOT-INF陷阱

              这个问题就很恶心了。这个时候你已经打包成功,你会发现运行jar的时候报错为file not found,而且不告诉你是什么文件。你打开jar去看,发现需要的lib,配置文件,class一样也不缺。

              其实这里要说一个概念,spring-boot在打包后,会把文件拷贝到BOOT-INF/Classes之下,这个时候你原来定义的扫描包路径将失效。而这个问题官方文档根本没讲,还是我没有看到。

              这个陷阱在你使用packages定义扫描路径的时候等着你。或者获取工程下文件的时候。对于获取文件的话,可以在原路径前加上classes,当然你要区分开发环境或生产环境的话,你可以使用profile或者conditional来解决。如果是扫描包路径就恶心了,因为你加上classes之后,不报file not found了。而是不报错,只是警告你找不到hibernate的某些xml。但是你很可能根本没有使用hibernate。
     

    参考博客:https://blog.csdn.net/guduyishuai/article/details/60968728

    parent工程pom文件:

    <?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.5.6.RELEASE</version>
        </parent>
    
        <groupId>com.demo</groupId>
        <artifactId>demo-parent</artifactId>
        <packaging>pom</packaging>
        <version>1.0-SNAPSHOT</version>
    
        <modules>
            <module>demo-base</module>
            <module>demo-sync</module>
            <module>demo-pattern</module>
        </modules>
    
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
            <java.version>1.8</java.version>
            <springboot.version>1.5.6</springboot.version>
        </properties>
    
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-devtools</artifactId>
            </dependency>
            <!--WEB层-->
            <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>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-eureka</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-ribbon</artifactId>
            </dependency>
    
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-actuator</artifactId>
            </dependency>
            <!-- framework启动器 模板引擎 -->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-freemarker</artifactId>
            </dependency>
            <dependency>
                <groupId>redis.clients</groupId>
                <artifactId>jedis</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.data</groupId>
                <artifactId>spring-data-redis</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-redis</artifactId>
                <version>1.3.7.RELEASE</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-jdbc</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-aspects</artifactId>
            </dependency>
            <!-- Mybatis -->
            <dependency>
                <groupId>org.mybatis</groupId>
                <artifactId>mybatis</artifactId>
                <version>3.2.8</version>
            </dependency>
            <dependency>
                <groupId>org.mybatis</groupId>
                <artifactId>mybatis-spring</artifactId>
                <version>1.3.2</version>
            </dependency>
    
            <!--fastjson-->
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>fastjson</artifactId>
                <version>1.2.8</version>
            </dependency>
            <!-- 分页助手 -->
            <dependency>
                <groupId>com.github.pagehelper</groupId>
                <artifactId>pagehelper</artifactId>
                <version>3.7.5</version>
            </dependency>
            <dependency>
                <groupId>com.github.jsqlparser</groupId>
                <artifactId>jsqlparser</artifactId>
                <version>0.9.1</version>
            </dependency>
            <!-- 通用Mapper -->
            <dependency>
                <groupId>com.github.abel533</groupId>
                <artifactId>mapper</artifactId>
                <version>2.3.4</version>
            </dependency>
            <!-- MySql连接驱动 -->
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
            </dependency>
            <!-- 连接池 -->
            <dependency>
                <groupId>com.jolbox</groupId>
                <artifactId>bonecp-spring</artifactId>
                <version>0.8.0.RELEASE</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter</artifactId>
                <exclusions>
                    <exclusion> <!-- exclude掉spring-boot的默认log配置 -->
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-logging</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <!-- log4j日志 -->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-log4j2</artifactId>
            </dependency>
    
            <!-- 有其他jar依赖log4j -->
            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-1.2-api</artifactId>
                <version>2.8.2</version>
            </dependency>
    
            <dependency>
                <groupId>com.lmax</groupId>
                <artifactId>disruptor</artifactId>
                <version>3.3.6</version>
            </dependency>
            
    		<!-- https://mvnrepository.com/artifact/org.dom4j/dom4j -->
    		<dependency>
    		    <groupId>org.dom4j</groupId>
    		    <artifactId>dom4j</artifactId>
    		    <version>2.1.0</version>
    		</dependency>
    
            <!--在线文档-->
            <!--swagger本身不支持spring mvc的,springfox把swagger包装了一下,让他可以支持springmvc-->
            <dependency>
                <groupId>io.springfox</groupId>
                <artifactId>springfox-swagger2</artifactId>
                <version>2.6.1</version>
            </dependency>
            <dependency>
                <groupId>io.springfox</groupId>
                <artifactId>springfox-swagger-ui</artifactId>
                <version>2.6.1</version>
            </dependency>
        </dependencies>
    
        <dependencyManagement>
            <dependencies>
                <dependency>
                    <groupId>org.springframework.cloud</groupId>
                    <artifactId>spring-cloud-dependencies</artifactId>
                    <version>Camden.SR7</version>
                    <type>pom</type>
                    <scope>import</scope>
                </dependency>
            </dependencies>
        </dependencyManagement>
        <build>
            <plugins>
                <!-- 资源文件拷贝插件 -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <configuration>
                        <encoding>UTF-8</encoding>
                    </configuration>
                </plugin>
                <!-- java编译插件 -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                        <encoding>UTF-8</encoding>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
            </plugins>
        </build>
    
    </project>
    

    base工程pom文件:

    <?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">
    
        <artifactId>demo-base</artifactId>
        <modelVersion>4.0.0</modelVersion>
    
        <parent>
            <groupId>com.demo</groupId>
            <artifactId>demo-parent</artifactId>
            <version>1.0-SNAPSHOT</version>
        </parent>
    
    	<build>
    		<plugins>
    			<plugin>
    				<groupId>org.springframework.boot</groupId>
    				<artifactId>spring-boot-maven-plugin</artifactId>
    				<configuration>
    					<classifier>exec</classifier>
    				</configuration>
    			</plugin>
    		</plugins>
    	</build>
    	
    </project>
    

    sync的pom文件:

    <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">
     
      <artifactId>demo-sync</artifactId>
      <modelVersion>4.0.0</modelVersion>
     
      <parent>
        <groupId>com.demo</groupId>
        <artifactId>demo-parent</artifactId>
        <version>1.0-SNAPSHOT</version>
      </parent>
      
      <dependencies>
      	<dependency>
      		<groupId>com.demo</groupId>
      		<artifactId>demo-base</artifactId>
      		<version>1.0-SNAPSHOT</version>
      	</dependency>
      </dependencies>
      
    </project>
    

     

    展开全文
  • spring-boot-starter-parent 包maven依赖报错

    千次阅读 2019-01-17 17:10:12
    看idea的日志发现这个依赖在某个路径下找不到,因为本人的maven配置的是公司的镜像,但是公司的镜像中不包含这个依赖,所以又添加了一个镜像,即可正常下载。 今天从 http://start.spring.io/ 下载的demo项目,导入...
  • 场景: springboot 项目多模块已成开发大势所趋,抽出一个parent父工程,子模块基础模块(包含一些公用的...即使能打包成功,用java -jar启动jar也会报Class Not Found,依赖的子模块工程的类找不到。 错误如下: maven-
  • 场景:因为之前用到的是,基于springboot框架所搭建的maven工程,而且都是相互独立的。现研发经理要求将所有工程进行整合和规范化,所以抽出一个parent父工程,base基础模块(包含一些公用的实体类和工具类等),以及其他子...
  • ![图片说明]...项目结构为:父工程:parent 下面有这5个子项目 现在要把manager打war包,manager依赖core和service ,但是现在manager打war包,会提示找不到依赖包里面的类,有什么办法吗?
  • 项目目录结构如图: !... dal ...在打包一个子项目,install 子pom时报错,如下: ...[DEBUG] ============================================... 进而导致报错说找不到依赖jar, 求教各位师傅,是否遇到过类似问题。
  • 文件结构如下 src src--package1 src--package2 src--package1--java文件 ...因为package2依赖package1里的java,这时报找不到package1 简单说就是怎么打包能 把package2依赖的java都打进来
  • 问题描述: idea中使用maven搭建springcloud项目,首先创建了一个app-parent父项目。然后再父项目下新建了两个module分别为module1和module2。然后将module1和module2打包,这时候是...就是找不到依赖的意思。...
  • springboot多工程,在使用maven进行打包的时候,一直提示“程序xxx不存在,找不到符号”,但项目是可以正常启动运行的,开始一直以为是maven哪里没有配置好导致的,后来才发现原来是springboot的maven插件导致的...
  •  这是我parent项目中pom文件的依赖管理  这是我要生成war那个工程最后依赖的jar,这个时候它们的版本号还是一致的 最后项目生成的:  下图是Dmaven.test.skip=true 跳过测试(同时会跳过test compile...
  • maven父子项目打包先后顺序问题

    千次阅读 2019-06-17 11:13:38
    demo2依赖demo1,则install或package demo2时必须先install parent和demo1,不能只install demo1 否则会报错找不到parent,demo1则可以直接install或package
  • springboot多工程,在使用maven进行打包的时候,一直提示“程序xxx不存在,找不到符号”,但项目是可以正常启动运行的,开始一直以为是maven哪里没有配置好导致的,后来才发现原来是springboot的maven插件导致的...
  • eclipse 多模块Maven项目打包指定模块

    千次阅读 2018-08-07 17:37:28
    一直在各种测试打包多模块下面的单独模块打包,一直报找不到依赖模块的jar,网上各种寻找,没有找到合适的内容,今天偶然发现有个提示要parent模块运行打包,经测试确实打包成功,记录一下。  在eclipse中,多...
  • 很大原因是因为maven的镜像问题找不到依赖包,所以需要换一个镜像。 因为我之前乱复制了一大堆镜像到maven的settting.xml,导致找不到,换了镜像就行了。 在pom.xml配置加上下面代码 <build> <finalName&...
  • springboot 多模块项目在本地运行好好的,一打包就出现 类找不到,符号找不到...当我么使用maven打包的时候发现,报错,类找不到符号等等 1.先在父项目的pom文件中使用maven插件 <plugins> <plug...
  • 在将其中一个web项目打包成war时,在tomcat中启动时提示找不到config.properties ![图片说明](https://img-ask.csdn.net/upload/202001/20/1579522003_255875.png) 下面是uitl模块的pom文件 ``` xsi:...
  • maven使用心得

    2012-01-12 19:41:36
    提示找不到parent库。 在maven2中,打 包依赖于reactor插件,可以这个打包过程最重要的就是找到其它工程的类,并加入到当前环境的classpath。 但我们的定义的父pom不会产生任何 的jar。所以没必要让子工程依赖于库...
  • MAVEN部署分析

    2016-12-05 16:18:22
    1.MAVEN的INSTALL方法是将对应的项目...2.子工程DEPENDENCYS的依赖报错,找不到父工程以上的JAR或者WAR的问题 需要重新INSTANLL 每次INSTANLL会在本地仓库的对应路径生成JAR或者WAR 然后子项目就可以找到
  • 代码报错记录-MAVEN

    2019-10-02 19:31:57
    说是找不到程序,我的JUNIT是父项目中的,子项目是从JAVA项目转为MAVEN项目的,难道在转成MAVEN项目时对POM文件的修改有误,后来发现 原因: 即对父项目的引用在构建的下面,导致构建时没有能获取父项目中的...
  • maven parent 中有一些子 module, 在parent pom.xml 执行 maven package时,报找不到storm core ,storm core 在parent 的pom.xml中有依赖,如下: <groupId>org.apache.storm <artifactId>storm-...
  • Spring Cloud 生成jar(包含模块依赖

    千次阅读 2018-05-02 18:02:02
    使用Sping Cloud 生成jar的过程,一直提示找不到依赖关系,但是在idea中启动并没有问题。处理方法如下: 1/ parent 模块的pom文件中添加 org.springframework.boot spring-boot-maven-plugin
  • # 到现在没找到新错误的原因 还是在报找不到dao的错误。 ## 实体类代码: ![图片说明](https://img-ask.csdn.net/upload/201910/10/1570672651_585106.jpg) ## controller代码: ``` package...

空空如也

空空如也

1 2 3
收藏数 44
精华内容 17
关键字:

mavenparent找不到依赖包