Search code examples
javamavenintellij-ideadcm4che

Adding dcm4che 5 library to Java project using IntelliJ and Maven


To preface - I'm a python dev, but I wanted to do some testing using Java. I've taken a few classes on Java at WGU, but I'm having an issue with getting a certain dependency installed and I'm thinking I'm just confusing myself.

The library I want to add - https://mvnrepository.com/artifact/org.dcm4che/dcm4che-core/5.32.1

It's noted that the dependency is located here - https://maven.dcm4che.org/

Here is my 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 https://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>3.3.1</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>org.example</groupId>
    <artifactId>migration</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>migration</name>
    <description>migration</description>
    <url/>
    <licenses>
        <license/>
    </licenses>
    <developers>
        <developer/>
    </developers>
    <scm>
        <connection/>
        <developerConnection/>
        <tag/>
        <url/>
    </scm>
    <properties>
        <java.version>17</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-j</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.dcm4che</groupId>
            <artifactId>dcm4che-core</artifactId>
            <version>5.32.1</version>
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>dcm4che-repo</id>
            <name>Dcm4che Repo</name>
            <url>https://maven.dcm4che.org/</url>
        </repository>
    </repositories>

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

</project>

But the error I'm receiving is "Failed to read artifact descriptor for org.dcm4che:dcm4che-core:jar:5.32.1" when trying to maven install. It looks like the version in that repo is actually vs 2.0.29, but I was hoping to use the latest version which appears to be 5.32.1 on mvnrepository.com.

Do I need to add the jars manually if they are not in the repo provided?

Thanks for any help.

I've seen the previous posts but again, they are using the older 2.0.29 versions, and I was hoping to use the latest in v5+


Solution

  • just change version 5.32.1 to 5.32.0

    <dependency>
        <groupId>org.dcm4che</groupId>
        <artifactId>dcm4che-core</artifactId>
        <version>5.32.0</version>
    </dependency>
    

    https://mvnrepository.com/artifact/org.dcm4che/dcm4che-parent

    you can find dcm4che-parent have 5.32.0 but no 5.32.1

    dcm4che-core 5.32.1 will lookup dcm4che-parent 5.32.1

    then get error message:

    Could not resolve dependencies for project org.example:migration:jar:0.0.1-SNAPSHOT: 
    
    Failed to collect dependencies at org.dcm4che:dcm4che-core:jar:5.32.1: 
    
    Failed to read artifact descriptor for org.dcm4che:dcm4che-core:jar:5.32.1: 
    
    The following artifacts could not be resolved: org.dcm4che:dcm4che-parent:pom:5.32.1 (absent): 
    
    Could not find artifact org.dcm4che:dcm4che-parent:pom:5.32.1 in dcm4che-repo (https://maven.dcm4che.org/
    

    just change version 5.32.1 to 5.32.0

    How to test and verify ?

    I am create an empty folder, then put your pom.xml into the folder.

    Then run command to test pom.xml config.

    mvn dependency:copy-dependencies -DoutputDirectory=target/libs
    

    after change the version to 5.32.0

    run command again:

    mvn dependency:copy-dependencies -DoutputDirectory=target/libs
    

    get

    [INFO] BUILD SUCCESS