Maven引入本地jar包,解决打包时找不到本地jar包

springboot,maven引入本地jar,生成pdf使用,找不到类问题
参考:Maven引入本地jar包,解决打包时找不到本地jar包

日志

Caused by: java.lang.NoClassDefFoundError: com/lowagie/text/DocumentException
        at net.sf.jasperreports.engine.JasperExportManager.exportToPdfStream(JasperExportManager.java:191)
        at net.sf.jasperreports.engine.JasperExportManager.exportReportToPdfStream(JasperExportManager.java:533)
Caused by: java.lang.ClassNotFoundException: com.lowagie.text.DocumentException
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:93)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 62 common frames omitted

pom

        
        <dependency>
            <groupId>net.sf.jasperreportsgroupId>
            <artifactId>jasperreportsartifactId>
            <exclusions>
                <exclusion>
                    <groupId>com.lowagiegroupId>
                    <artifactId>itextartifactId>
                exclusion>
            exclusions>
        dependency>
        <dependency>
            <groupId>net.sf.jasperreportsgroupId>
            <artifactId>jasperreports-metadataartifactId>
        dependency>
        <dependency>
            <groupId>net.sf.jasperreportsgroupId>
            <artifactId>jasperreports-functionsartifactId>
            <exclusions>
                <exclusion>
                    <groupId>com.lowagiegroupId>
                    <artifactId>itextartifactId>
                exclusion>
            exclusions>
        dependency>
        
        <dependency>
            <groupId>com.lowagiegroupId>
            <artifactId>itextartifactId>
            <version>2.1.7.js6version>
            <scope>systemscope>
            <systemPath>${project.basedir}/src/main/resources/libs/itext-2.1.7.js6.jarsystemPath>
        dependency>
        
        <dependency>
            <groupId>com.itextpdfgroupId>
            <artifactId>itextpdfartifactId>
        dependency>
        <dependency>
            <groupId>com.itextpdfgroupId>
            <artifactId>itext-asianartifactId>
        dependency>

解决方式


    <build>
        <finalName>...finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.bootgroupId>
                <artifactId>spring-boot-maven-pluginartifactId>
                <configuration>
                    <mainClass>${start-class}mainClass>
                    
                    <includeSystemScope>trueincludeSystemScope>
                configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackagegoal>
                        goals>
                    execution>
                executions>
            plugin>
            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-jar-pluginartifactId>
                <executions>
                    <execution>
                        <id>default-jarid>
                        <phase>packagephase>
                        <goals>
                            <goal>jargoal>
                        goals>
                    execution>
                executions>
                

            plugin>
            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-deploy-pluginartifactId>
                <configuration>
                    <skip>trueskip>
                configuration>
            plugin>
        plugins>
    build>

你可能感兴趣的:(springboot,idea,maven,spring,boot,java,error,maven,pom)