Failed to start springboot project

problem description

springboot failed to start

the environmental background of the problems and what methods you have tried

springboot failed to start, and console has a lot of error messages
at first, springboot could not find mapper, and then read the Q & An and found that mapper could be annotated with @ component
, but there were a lot of errors as soon as it started. (I just learned springboot, and followed the online tutorials. I don"t know what"s wrong.)

related codes

/ / Please paste the code text below (do not replace the code with pictures)

< hr > < H2 > SpringbootApplication.java < / H2 > < hr >
package com.luc.springboot;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@MapperScan("com.luc.springboot.mapper")
public class SpringbootApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringbootApplication.class, args);
    }
}
< hr > < H2 > application.yml < / H2 > < hr >
server:
  port: 8080
-sharp  servlet:
-sharp    context-path: /hello
spring:
  mvc:
    view:
      prefix: /WEB-INF/views/
      suffix: .jsp

  datasource:
    url: jdbc:mysql://localhost:3306/test?characterEncoding=UTF-8
    username: root
    password: admin
    driver-class-name: com.mysql.jdbc.Driver -sharp  com.mysql.cj.jdbc.Driver
  jpa:
    show-sql: true
    hibernate:
      ddl-auto: update
-sharpdebug: true

-sharp 
luc:
  title: abcde
  description: abcde
-sharp  log 
logging:
  path: classpath:/log.txt
-sharp  level: debug
-sharp   log 
< hr > < H2 > StudentMapper.java < / H2 > < hr >
package com.luc.springboot.mapper;

import com.luc.springboot.domain.Student;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface StudentMapper{
    @Select("select * from student")
    List<Student> findALL();
}
< H2 > StudentController.java < / H2 >
package com.luc.springboot.controller;

import com.luc.springboot.domain.Student;
import com.luc.springboot.mapper.StudentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class StudentController {

    @Autowired
    private StudentMapper studentMapper;

    @RequestMapping("/student")
    public String student(){
        List<Student> students = studentMapper.findALL();
        return students.toString();
    }
}

what result do you expect? What is the error message actually seen?

the expected result must be that you want to run normally

error message (too much, I didn"t intercept general information)
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.
2018-11-08 11 INFO 35 restartedMain 07.988 INFO 5820-[restartedMain] com.zaxxer.hikari.HikariDataSource: HikariPool-1-Starting.
2018-11-08 11 Fringe 35 Switzerland 07.988 WARN 5820-[restartedMain] com.zaxxer.hikari.util.DriverDataSource: Registered driver with driverClassName=com.mysql.jdbc.Driver was not found, Trying direct instantiation.
2018-11-08 11 ERROR 5820-[restartedMain] com.zaxxer.hikari.pool.HikariPool: HikariPool-1-Exception during pool initialization.
java.sql.SQLException: The server time zone value "given host is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.

at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) ~[mysql-connector-java-8.0.13.jar:8.0.13]
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) ~[mysql-connector-java-8.0.13.jar:8.0.13]

2018-11-08 11 o.s.b.a.orm.jpa.DatabaseLookup: Unable to determine jdbc url from datasource 35 o.s.b.a.orm.jpa.DatabaseLookup: Unable to determine jdbc url from datasource 09.491 WARN 5820-[restartedMain]

org.springframework.jdbc.support.MetaDataAccessException: Could not get Connection for extracting meta-data; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: The server time zone value "assigned host is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.

at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:328) ~[spring-jdbc-5.1.2.RELEASE.jar:5.1.2.RELEASE]
at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:356) ~[spring-jdbc-5.1.2.RELEASE.jar:5.1.2.RELEASE]

2018-11-08 11 Freight 35 ERROR 10.831 ERROR 5820-[restartedMain] com.zaxxer.hikari.pool.HikariPool: HikariPool-1-Exception during pool initialization.

java.sql.SQLException: The server time zone value "assigned host is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.

at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) ~[mysql-connector-java-8.0.13.jar:8.0.13]
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) ~[mysql-connector-java-8.0.13.jar:8.0.13]


2018-11-08 11 11 WARN 5820-[restartedMain] o.h.e.j.e.i.JdbcEnvironmentInitiator: HHH000342: Could not obtain connection to query metadata: The server time zone value "assigned host is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
2018-11-08 11 Freight 35 WARN 10.836 WARN 5820-[restartedMain] ConfigServletWebServerApplicationContext: Exception encountered during context initialization-cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name "entityManagerFactory" defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; Nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name "studentMapper" defined in file [D:ProjectJavaWebProjectspringbootspringboottargetclassescomlucspringbootmapperStudentMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property" sqlSessionFactory" or "sqlSessionTemplate" are required

2018-11-08 11 11 Fraser 35 ERROR 10.858 ERROR 5820-[restartedMain] o.s.boot.SpringApplication: Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name "entityManagerFactory" defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1745) ~[spring-beans-5.1.2.RELEASE.jar:5.1.2.RELEASE]



Oct.30,2021

first of all, the problem that causes the program not to start is that com.zaxxer.hikari.pool.HikariPool was not successfully created by Spring because your time zone configuration is ambiguous. You need to add an unambiguous value such as & serverTimezone=Asia/Shanghai after jdbc url.

in addition, according to the prompt, your driver string should be com.mysql.jdbc.Driver , the new version has been changed to com.mysql.cj.jdbc.Driver .

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e4892b-44cc4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e4892b-44cc4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?