Error for importing JDBC from sqlServer with Maven

3

In my web java application, I needed to add a connection to a sql server database, so I put it as maven dependency as described below:

<dependency>
        <groupId>com.microsoft.sqlserver</groupId>
        <artifactId>mssql-jdbc</artifactId>
        <version>6.4.0.jre8</version>
        <scope>compile</scope>
    </dependency>

The dependency has been downloaded and is within the m2 folder.

Running the application locally on my machine, everything works with the import code below:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import com.microsoft.sqlserver.jdbc.SQLServerDriver;

However, after generating the WAR project with the mvn clean package -DskipTests -Pdev comma and published inside a development server, I get the following error:

  

Root cause of ServletException. java.lang.NoClassDefFoundError:   com / microsoft / sqlserver / jdbc / SQLServerDriver

I believe that either I'm importing the wrong code or forgot to set something up for maven.

I also noticed that after running the maven command the dependency is placed within WEB-INF\lib according to the other dependencies, but my application can not find, can anyone help me?

    
asked by anonymous 06.08.2018 / 17:00

0 answers