Could not find artifact javax.sql:jdbc-stdext:jar:

2019-05-22 20:25发布

问题:

I'm trying to build a REST API of web Services I created for my project. My web services are working without problems.

Now, I want to Deploy my Services on a distant server and I need to generate the war file.

I'm using Java, Eclipse and Maven for dependencies. I tried to make a clean install and the only problem of failure is that :

[WARNING] The artifact jdbc:jdbc:jar:2.0 has been relocated to javax.sql:jdbc-stdext:jar:2.0
[INFO] Downloading: https://repo.maven.apache.org/maven2/javax/sql/jdbc-stdext/2.0/jdbc-stdext-2.0.jar
Could not find artifact javax.sql:jdbc-stdext:jar:2.0 in central (https://repo.maven.apache.org/maven2), try downloading from http://java.sun.com/products/jdbc/download.html

Anyone has a solution ?

P.S : Why i didn't face the problem while testing is because I added the jdbc-stdext-2.0.jar manually and now I'm in troubles.

My Pom.xml

<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Tech4EarthServices</groupId>
<artifactId>Tech4EarthServices</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <warSourceDirectory>WebContent</warSourceDirectory>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>asm</groupId>
        <artifactId>asm</artifactId>
        <version>3.3.1</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish.jersey.core</groupId>
        <artifactId>jersey-server</artifactId>
        <version>2.17</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <artifactId>jersey-container-servlet-core</artifactId>
        <version>2.17</version>
    </dependency>
    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20140107</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-core</artifactId>
        <version>2.6.0</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.6.0</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-annotations</artifactId>
        <version>2.6.0</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish.jersey.media</groupId>
        <artifactId>jersey-media-json-jackson</artifactId>
        <version>2.19</version>
    </dependency>
    <dependency>
        <groupId>jdbc</groupId>
        <artifactId>jdbc</artifactId>
        <version>2.0</version>
        <exclusions>
            <exclusion>
                <artifactId>jdbc-stdext</artifactId>
                <groupId>javax.sql</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.6</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>4.1.7.RELEASE</version>
    </dependency>
</dependencies>

回答1:

I believe this is because you listed the artifact as an exclusion in your pom. i.e

<exclusions>
    <exclusion>
        <artifactId>jdbc-stdext</artifactId>
        <groupId>javax.sql</groupId>
    </exclusion>
</exclusions>

I think if you remove this block you will be fine



回答2:

You experience the problem because you are including artifacts that have only source packages available. The maven dependency for jdbc.jdbc is referenced as a binary.

Most probably you don't need to include that dependency because those interfaces are provided by the JEE containers that you run your WAR archive in. I would recommend removing the jdbc artifact with the exlusion part entirely.

You can browse as what is available at jdbc/jdbc folder at Maven Central. And indeed the extension for it has removed under javax/sql at Maven Central.