C
C
chelovek_rediska2016-10-14 16:51:04
Java
chelovek_rediska, 2016-10-14 16:51:04

When building a project via MAVEN, the JDBC driver flies off, how to pack it together with the project?

After building the project with the build command into a jar file, the program stops seeing jdbc. The driver is added as a library in IDEA.
Here is the pom file itself:

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>usapedia</groupId>
    <artifactId>Usapedia</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>

<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
    <dependencies>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.40</version>
    </dependency>
    </dependencies>


    <build>
        <finalName>Usapedia</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <archive>
                        <manifest>
                            <!-- Jar file entry point -->
                            <mainClass>Main</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

efafb9fb7d8a413f9ce0e81dcbd68536.PNGError output:
8ee831c02c0c417797f0d605f4c4eab7.PNG

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
chelovek_rediska, 2016-10-14
@chelovek_rediska

Solved the problem with packing all dependencies into a jar file with the shade plugin maven.apache.org/plugins/maven-shade-plugin

M
mipan, 2016-10-14
@mipan

add it via pom

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question