学习 Java 报表技术导入 Maven 依赖出错:jacob 无法下载、jasperreports 依赖错误

发生缘由

最近在做一个可视化项目,用到了 Java 报表技术。在跟着「黑马」课程导入 pom.xml 文件的时候提示下载依赖错误。

  • com.jacob 包无法下载
  • Failed to read artifact descriptor for com.lowagie:itext:jar:2.1.7.js6

运行环境

  • 电脑系统版本:Windows 10 64bit
  • Idea:2023.2 (Ultimate Edition)
  • Maven:apache-maven-3.6.0

问题解决

解决 jacob 包问题

既然阿里云无法下载,那么直接从 GitHub 下载即可。文件也不大,才500KB,所以使用下面哪种方式都可以。

Release 下载页面、jacob-1.20.zip下载链接、百度网盘、蓝奏云

# 将压缩包下载本地并解压
E:\JAVA\jar\jacob-1.20> dir
 驱动器 E 中的卷是 软件
 卷的序列号是 9692-5EC7

2020-09-25  06:22    <DIR>          .
2020-09-25  06:22    <DIR>          ..
2020-09-24  23:21    <DIR>          docs
2020-09-25  06:16           226,816 jacob-1.20-x64.dll
2020-09-25  06:16           189,440 jacob-1.20-x86.dll
2020-09-25  06:15            49,913 jacob.jar
2020-09-24  23:21            26,440 LICENSE.TXT
               4 个文件        492,609 字节
               3 个目录 52,337,233,920 可用字节
# 安装到 Maven 仓库中
E:\JAVA\jar\jacob-1.20>mvn install:install-file -DgroupId=com.jacob -DartifactId=jacob -Dversion=1.20 -Dpackaging=jar -Dfile=jacob.jar

解决 jasperreports 依赖

这个是重复依赖问题,只需要在导入其的时候将有影响的包排除掉即可。

<dependency>
    <groupId>net.sf.jasperreportsgroupId>
    <artifactId>jasperreportsartifactId>
    <version>6.5.0version>
    <exclusions>
        
        <exclusion>
            <groupId>com.lowagiegroupId>
            <artifactId>itextartifactId>
        exclusion>
        
        <exclusion>
            <groupId>org.olap4jgroupId>
            <artifactId>olap4jartifactId>
        exclusion>
    exclusions>
dependency>

最后 pom 文件

<dependencies>
    
    
    <dependency>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-starter-webartifactId>
    dependency>
    
    <dependency>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-starter-testartifactId>
    dependency>


    
    
    <dependency>
        <groupId>mysqlgroupId>
        <artifactId>mysql-connector-javaartifactId>
        <version>5.1.47version>
    dependency>
    
    <dependency>
        <groupId>tk.mybatisgroupId>
        <artifactId>mapper-spring-boot-starterartifactId>
        <version>2.1.4version>
    dependency>
    
    <dependency>
        <groupId>com.github.pagehelpergroupId>
        <artifactId>pagehelper-spring-boot-starterartifactId>
        <version>1.2.10version>
    dependency>


    
    
    <dependency>
        <groupId>net.sourceforge.jexcelapigroupId>
        <artifactId>jxlartifactId>
        <version>2.6.12version>
    dependency>
    
    <dependency>
        <groupId>org.apache.poigroupId>
        <artifactId>poiartifactId>
        <version>4.0.1version>
    dependency>
    
    <dependency>
        <groupId>org.apache.poigroupId>
        <artifactId>poi-ooxmlartifactId>
        <version>4.0.1version>
    dependency>
    
    <dependency>
        <groupId>org.apache.poigroupId>
        <artifactId>poi-ooxml-schemasartifactId>
        <version>4.0.1version>
    dependency>
    
    <dependency>
        <groupId>com.opencsvgroupId>
        <artifactId>opencsvartifactId>
        <version>4.5version>
    dependency>
    
    
    <dependency>
        <groupId>com.jacobgroupId>
        <artifactId>jacobartifactId>
        <version>1.20version>
    dependency>

    
    
    <dependency>
        <groupId>net.sf.jasperreportsgroupId>
        <artifactId>jasperreportsartifactId>
        <version>6.5.0version>
        
        <exclusions>
            
            <exclusion>
                <groupId>com.lowagiegroupId>
                <artifactId>itextartifactId>
            exclusion>
            
            <exclusion>
                <groupId>org.olap4jgroupId>
                <artifactId>olap4jartifactId>
            exclusion>
        exclusions>
    dependency>
    
    <dependency>
        <groupId>org.olap4jgroupId>
        <artifactId>olap4jartifactId>
        <version>1.2.0version>
    dependency>
    
    <dependency>
        <groupId>com.lowagiegroupId>
        <artifactId>itextartifactId>
        <version>2.1.7version>
    dependency>
    
    <dependency>
        <groupId>org.jfreegroupId>
        <artifactId>jfreechartartifactId>
        <version>1.5.0version>
    dependency>


    
    
    <dependency>
        <groupId>org.projectlombokgroupId>
        <artifactId>lombokartifactId>
    dependency>
    
    <dependency>
        <groupId>org.apache.commonsgroupId>
        <artifactId>commons-lang3artifactId>
    dependency>
dependencies>

你可能感兴趣的:(那些年遇到的BUG,java,学习,maven)