zoukankan      html  css  js  c++  java
  • Maven依赖war开发,找不到war里头的class解决方案

    问题描述:

    开发一个web系统,需要引用另一个excel.war【在该系统里头是一个excel的导入导出小模块】进行项目

                <dependency>
                    <groupId>com.bosssoft.platform.component</groupId>
                    <artifactId>com.bosssoft.platform.common.excel</artifactId>
                    <version>${project.version}</version>
                    <type>war</type>
                </dependency>

    在开发过程中,发现引用不到excel.war里头的class文件,但是maven clean install出来的web系统的war,里头又有相关的class文件

    后面百度了,经过多方排查,是因为有些IDE没法很智能的做到,直接去引用war里头的class,这个时候我们在打包excel.war的时候,就要打包class的资源。

        <build>
            <finalName>com.bosssoft.platform.common.excel</finalName>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <configuration>
                        <!--将class打包jar作为附件-->
                        <attachClasses>true</attachClasses>
                        <failOnMissingWebXml>false</failOnMissingWebXml>
                    </configuration>
                </plugin>
            </plugins>
        </build>

    注意红色字体部分,在进行打包的时候,同样要打出一个jar的class资源包,进行依赖。

    在进行项目依赖的时候加个class资源就可以了

            <dependency>
                <groupId>com.bosssoft.platform.component</groupId>
                <artifactId>com.bosssoft.platform.common.excel</artifactId>
                <type>war</type>
            </dependency>
            
            <dependency>
                <groupId>com.bosssoft.platform.component</groupId>
                <artifactId>com.bosssoft.platform.common.excel</artifactId>
                <classifier>classes</classifier>
            </dependency>

    bingo,解决了

  • 相关阅读:
    【Python】ModuleNotFoundError: No module named 'matplotlib.pyplot'
    【DB2】DB2使用IMPORT命令导入含有自增长列的表报错处理
    ~~
    汉字的unicode码范围是多少?
    字符编码(ASCII,Unicode和UTF-8) 和 大小端(zz)
    是否 whether ,if
    定语从句:
    by,with
    C++中extern “C”含义深层探索
    安装Office2007时出现1706错误的解决方案
  • 原文地址:https://www.cnblogs.com/shawWey/p/9187451.html
Copyright © 2011-2022 走看看