Mesmo alterando no application.proporties o driver do mysql para com.mysql.cj.jdbc.Driver, no servidor da falha de com.mysql.jdbc.Driver depreciado.

JPA

JDBC

Spring Boot

04/02/2021

Olá,

Estou com um problema bem incomum e não consegui nada nos fóruns que explicasse o tal comportamento.
Eu tinha um sistema com SPRING BOOT com conexão a um banco de dados MYSQL. Eu fiz uma atualização no arquivo pom para injetar dependências mais recentes. O arquivo pom era o seguinte:

<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>com.sistemaexemplo</groupId>
  <artifactId>app</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>

  <name>app</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  	<dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
      <version>1.5.6.RELEASE</version>
    </dependency>
	<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-tomcat -->
	<dependency>
	    <groupId>org.springframework.boot</groupId>
	    <artifactId>spring-boot-starter-tomcat</artifactId>
	    <version>1.5.11.RELEASE</version>
	</dependency>
	<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa -->
	<dependency>
	    <groupId>org.springframework.boot</groupId>
	    <artifactId>spring-boot-starter-data-jpa</artifactId>
	    <version>1.5.6.RELEASE</version>
	</dependency>
	<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
	<dependency>
	    <groupId>mysql</groupId>
	    <artifactId>mysql-connector-java</artifactId>
	    <version>5.1.6</version>
	</dependency>
	<dependency>
	  <groupId>com.mysema.querydsl</groupId>
	  <artifactId>querydsl-apt</artifactId>
	  <version>3.6.6</version>
	  <scope>provided</scope>
	</dependency>
	<dependency>
	  <groupId>com.mysema.querydsl</groupId>
	  <artifactId>querydsl-jpa</artifactId>
	  <version>3.6.6</version>
	</dependency>
	<dependency>
	    <groupId>com.fasterxml.jackson.core</groupId>
	    <artifactId>jackson-databind</artifactId>
	    <version>2.9.4</version>
	</dependency>
	<!-- send email -->
	<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-mail -->
	<dependency>
	    <groupId>org.springframework.boot</groupId>
	    <artifactId>spring-boot-starter-mail</artifactId>
	    <version>2.2.7.RELEASE</version>
	</dependency>
  </dependencies>

  // OBS: a parte do build ficou cortada
</project>


Eu alterei para:

<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>com.sistemaexemplo</groupId>
  <artifactId>app</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.3.3.RELEASE</version>
		<relativePath />
	</parent>

  <name>app</name>
  <url>http://maven.apache.org</url>

<properties>
	<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
	<java.version>1.8</java.version>
</properties>

  <dependencies>
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-security</artifactId>
	</dependency>
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-web</artifactId>
	</dependency>
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-test</artifactId>
		<scope>test</scope>
	</dependency>
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-data-jpa</artifactId>
		<scope>compile</scope>
	</dependency>
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-mail</artifactId>
	</dependency>
	<dependency>
		<groupId>io.jsonwebtoken</groupId>
		<artifactId>jjwt</artifactId>
		<version>0.6.0</version>
	</dependency>
 <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jdbc</artifactId>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
	<dependency>
	  <groupId>com.mysema.querydsl</groupId>
	  <artifactId>querydsl-apt</artifactId>
	  <version>3.6.6</version>
	  <scope>provided</scope>
	</dependency>
	<dependency>
	  <groupId>com.mysema.querydsl</groupId>
	  <artifactId>querydsl-jpa</artifactId>
	  <version>3.6.6</version>
	</dependency>
	<!-- https://mvnrepository.com/artifact/org.modelmapper/modelmapper -->
	<dependency>
	    <groupId>org.modelmapper</groupId>
	    <artifactId>modelmapper</artifactId>
	    <version>2.3.9</version>
	</dependency>
	<dependency>
		<groupId>ch.qos.logback</groupId>
		<artifactId>logback-classic</artifactId>
	</dependency>
	<dependency>
		<groupId>org.slf4j</groupId>
		<artifactId>jul-to-slf4j</artifactId>
	</dependency>
	<dependency>
		<groupId>org.slf4j</groupId>
		<artifactId>log4j-over-slf4j</artifactId>
	</dependency>
  </dependencies>

// OBS: a parte do build ficou cortada
</project>


Arquivo


spring.jpa.hibernate.ddl-auto=none

spring.datasource.url=jdbc:mysql://host:3306/sistemam_dev?useTimezone=true&serverTimezone=UTC&useLegacyDatetimeCode=true
spring.datasource.username=user
spring.datasource.password=pass
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

server.port= 8088




Ao fazer fazer o deploy para o servidor toncat recebo o erro:

04-Feb-2021 02:01:28.084 INFO [Catalina-utility-1] org.apache.catalina.startup.HostConfig.undeploy Undeploying context []
Loading class `com.mysql.jdbc.Driver''''. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver''''. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
04-Feb-2021 02:01:28.114 WARNING [Catalina-utility-1] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ROOT] appears to have started a thread named [mysql-cj-abandoned-connection-cleanup] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Thread.run(Thread.java:744)
04-Feb-2021 02:01:28.153 INFO [Catalina-utility-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [/home/sistemaexemplo/jvm/apache-tomcat-9.0.21/domains/apihomologacao.sistemaexemplo.com/ROOT.war]
04-Feb-2021 02:01:30.972 INFO [Catalina-utility-1] org.apache.catalina.core.ApplicationContext.log 1 Spring WebApplicationInitializers detected on classpath
04-Feb-2021 02:01:31.063 INFO [Catalina-utility-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
...
Alan

Alan

Curtidas 0
POSTAR