2.2K Star 15.6K Fork 9.3K

JEECG / jeecg-boot

 / 详情

瘦jar打包方式下,所有 excel 文件导入失败

已完成
创建于  
2021-09-30 16:35
版本号:v2.4.6
问题描述:

系统管理菜单下的所有导入功能都失败,错误提示是 —— 文件导入失败 java.lang.NullPointerException: null。

截图&代码:

输入图片说明
经过定位,问题发生在:
Caused by: java.lang.NullPointerException: null
at org.jeecgframework.poi.util.PoiPublicUtil.getWebRootPath(PoiPublicUtil.java:301).

class PoiPublicUtil 的 301 行位置的代码是:
path = PoiPublicUtil.class.getClassLoader().getResource("").toURI().getPath();
返回 null 的是 getResource("")

评论 (12)

阿杜 创建了任务
阿杜 关联仓库设置为JEECG开源社区/jeecg-boot
展开全部操作日志

什么情况下出现的?本地运行还是服务器部署

发布到 CentOS7.6 上的微服务部署场景下发生的。

问下,打包的时候怎么配置的?

不好意思,最近加班多,忘记这边提的 issue 了。

对比代码是否有出入,然后确定下windows是否正常
输入图片说明

瘦 jar 打包方式修改了官方v2.4.6源码中,jeecg-cloud-module => jeecg-cloud-system-start 子模块的 pom.xml,修改内容如下:
输入图片说明

您好,您这问题解决了吗?我用assembly打包,也有同样的问题。

非瘦身打包有问题吗

直接打成一个jar包,我这边是好的。用assembly打包,分离到lib中就不行。能帮忙看下吗?

pom.xml

<plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            &lt;!&ndash;运行jar包时运行的主类,要求类全名&ndash;&gt;
                            <mainClass>org.feike.SystemCloudApplication</mainClass>
                            &lt;!&ndash; 是否指定项目classpath下的依赖 &ndash;&gt;
                            <addClasspath>true</addClasspath>
                            &lt;!&ndash; 指定依赖的时候声明前缀 &ndash;&gt;
                            <classpathPrefix>./</classpathPrefix>
                            &lt;!&ndash;依赖是否使用带有时间戳的唯一版本号,如:xxx-1.3.0-20121225.012733.jar&ndash;&gt;
                            <useUniqueVersions>false</useUniqueVersions>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    &lt;!&ndash; 配置执行器 &ndash;&gt;
                    <execution>
                        <id>make-assembly</id>
                        &lt;!&ndash; 绑定到package生命周期阶段上 &ndash;&gt;
                        <phase>package</phase>
                        <goals>
                            &lt;!&ndash; 只运行一次 &ndash;&gt;
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            &lt;!&ndash;生成包的末尾添加assembly id,一般关闭 &ndash;&gt;
                            <appendAssemblyId>false</appendAssemblyId>
                            <finalName>${project.artifactId}-${project.version}</finalName>
                            &lt;!&ndash;加载指定的配置文件&ndash;&gt;
                            <descriptors>
                                <descriptor>src/main/assembly/assembly.xml</descriptor>
                            </descriptors>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>

assembly.xml

<assembly>
    <id>唯一编号</id>
    <formats>
        <!--支持 zip,tar,tar.gz,tar.bz2,jar,dir,war 等 -->
        <format>tar.gz</format>
    </formats>
    <!--tar.gz压缩包下是否生成和项目名相同的根目录-->
    <includeBaseDirectory>true</includeBaseDirectory>
    <fileSets>
        <fileSet>
            <directory>src/main/bin</directory>
            <outputDirectory>/</outputDirectory>
            <!-- Linux权限 -->
            <fileMode>0755</fileMode>
        </fileSet>
        <fileSet>
            <directory>target/classes/META-INF/conf</directory>
            <outputDirectory>conf/META-INF/conf</outputDirectory>
            <!-- Linux权限 -->
            <fileMode>0644</fileMode>
        </fileSet>
        <fileSet>
            <directory>target/classes</directory>
            <outputDirectory>config</outputDirectory>
            <fileMode>0644</fileMode>
            <includes><!-- 只负责这些目标文件-->
                <include>*.properties</include>
                <include>*.yml</include>
                <include>*.xml</include>
                <include>**/*.xml</include>
                <include>**/*.properties</include>
            </includes>
        </fileSet>
    </fileSets>
    <!-- 输出到lib路径 -->
    <dependencySets>
        <dependencySet>
            <!--是否在最外层套一个本项目的名称的文件目录-->
            <useProjectArtifact>true</useProjectArtifact>
            <!-- 输出到这个路径下 -->
            <outputDirectory>lib</outputDirectory>
            <!--将scope为runtime的依赖包打包-->
            <scope>runtime</scope>
        </dependencySet>
    </dependencySets>
</assembly>

已修复,下个版本

autopoi升级到1.3.6版本
<autopoi-web.version>1.3.6</autopoi-web.version>

JEECG 任务状态待办的 修改为已完成

登录 后才可以发表评论

状态
负责人
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
参与者(4)
57093 jeecg 1662000782 469422 tygo 1607052856 7432037 feike feng 1636681357
Java
1
https://gitee.com/jeecg/jeecg-boot.git
git@gitee.com:jeecg/jeecg-boot.git
jeecg
jeecg-boot
jeecg-boot

搜索帮助