Tag Archives: springBoot

SpringBoot Frame: Failed to determine a suitable driver class [How to Solve]

. ____ _ __ _ _
/\\/___’_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | ‘_ | ‘_| | ‘_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
‘ |____| .__|_| |_|_| |_\__, |////
:: Spring Boot :: (v2.0.7.RELEASE)

2019-08-27 11:31:57.774 ERROR 15364 — [ main] o.s.b.d.LoggingFailureAnalysisReporter :



Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded datasource could be configured.

Reason: Failed to determine a suitable driver class


Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).


Build a simple introductory test based on springboot and springcloud framework. The error report is as follows:


This is because the database component is added, so autoconfig will read the data source configuration, but the newly created project has not been configured. The data source/url address is wrong, so an exception will occur.


1. Add exclude = {datasourceautoconfiguration. Class} in @ enableautoconfiguration or @ springbootapplication of startup class to exclude autoconfig of this class. After startup, it can run normally.

1 @MapperScan("com.wsc.core.mapper")
2 @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
  // SpringBoot
3 public class Start {
4     public static void main(String[] args) {
5         SpringApplication.run(Start.class,args);
6     }
7 }

II. The URL address in application.yml cannot be recognized, and the format is wrong.

Strict writing requirements for yaml format files (equal order flush, top grid input)

 1 server:
 2   port: 8001
 3 mybatis:
 4   config-location: classpath:mybatis/mybatis.cfg.xml #mybatis Configuration file path
 5 type-aliases-package: com.wsc.core.pojo # package where the entity alias class is located
 6 mapper-locations: mybatis/mapper/*.xml # mapper mapping file
 7 spring:
 8 application:
 9 name: microserver-product # This is very important, this is generally based on this name in the future service to service calls between each other
10 datasource:
11 type: com.alibaba.druid.pool.
12 driver-class-name: com.mysql.cj.jdbc.
13 url: jdbc:mysql://
14 password: wsc
15 username: root
16 dbcp2:
17 min-idle: 5 # Minimum number of maintained connections for the database connection pool
18 initial-size: 5 # Initialize the number of connections
19 max-total: 5 # Maximum number of connections
20 max-wait-millis: 150 # Maximum timeout to wait for a connection to be fetched

YML file

Springboot project startup prompt error: (3, 37) Java: package org.mybatis.spring.annotation does not exist

#Error: (3, 37) Java: package org.mybatis.spring.annotation does not exist

Generally, there is no problem with the configuration when pulling items from GIT and running. This will be prompted when starting

Refactoring is also ineffective at this time. Most of them are caused by this problem

Open the settings and check the blue box as shown in the figure

Then start the OK solution

[Solved] Error reported when adding ojdbc6 to springboot

Generally, adding ojdbc6 database driver to springboot will report an error, and the dependency cannot be added. The reason is that the ojdbc6 database driver is charged and cannot be downloaded directly through Maven. You need to download ojdbc6.jar manually and add it to your own warehouse manually

The first step is to download the jar package of ojdbc6


Select jar to download it

Step 2 rename ojdbc6 the downloaded jar and put it in the directory of the C disk user

Step 3 open the CMD window from this directory

Execute command

mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion= -Dpackaging=jar -Dfile=ojdbc6.jar

Add it to your Maven

This indicates that the addition was successful

Step 4 go to your own warehouse to check


The jar package has been added

If you just add a dependency, you won’t report an error


The thymeleaf engine in springboot reports an error [Solved]

Error reported by thymeleaf:

An error happened during template parsing (template: “class path resource [templates/hello.html]”)] with root cause……

Each of the following is a single solution! Not a step

1. Clear your compiler cache! And restart

2. Clear the browser cache Ctrl + Shift + Del

3. Check the configuration file (. POM file): whether it contains dependencies. If not, please add it


4. In application. properties

#Set prefix and suffix

5. Is it a coding problem? The code here refers to the code with errors, syntax, and other problems


Springboot startup error yamlexception/malformedinputexception input length = 1

Test springboot locally, and the startup error is as follows:

21:04:19.284 [restartedMain] ERROR org.springframework.boot.SpringApplication - Application run failed
java.lang.IllegalStateException: Failed to load property source from location 'classpath:/application.yml'
	at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:545)
Caused by: org.yaml.snakeyaml.error.YAMLException: java.nio.charset.MalformedInputException: Input length = 1
Caused by: java.nio.charset.MalformedInputException: Input length = 1

Finally, it is found that the encoding problem of application.yml file is changed from GBK to UTF-8

Springboot always reports an error when importing JSP dependencies

Paste my own POM code first:

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 3     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
 4     <modelVersion>4.0.0</modelVersion>
 5     <parent>
 6         <groupId>org.springframework.boot</groupId>
 7         <artifactId>spring-boot-starter-parent</artifactId>
 8         <version>1.5.6.RELEASE</version>
 9         <relativePath/> <!-- lookup parent from repository -->
10     </parent>
11     <groupId>com.sblueice</groupId>
12     <artifactId>demo</artifactId>
13     <version>0.0.1-SNAPSHOT</version>
14     <packaging>war</packaging>
15     <name>demo</name>
16     <description>Demo project for Spring Boot</description>
18     <properties>
19         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
20         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
21         <java.version>1.8</java.version>
22     </properties>
24     <dependencies>
25         <dependency>
26             <groupId>org.springframework.boot</groupId>
27             <artifactId>spring-boot-starter-web</artifactId>
28         </dependency>
29         <dependency>
30             <groupId>javax.servlet</groupId>
31             <artifactId>javax.servlet-api</artifactId>
32             <scope>provided</scope>
33         </dependency>
35          <!--sppourt jsp -->
36         <dependency>
37               <groupId>javax.servlet</groupId>
38               <artifactId>jstl</artifactId>
39               <version>1.2</version>
40         </dependency>
42        <dependency>
43         <groupId>com.mchange</groupId>
44         <artifactId>c3p0</artifactId>
45         <version></version>
46     </dependency>
47         <!-- Setting it to provided will exclude the package when packaging, as it is not needed to be put into a standalone tomcat to run. -->
48         <dependency>
49             <groupId>org.springframework.boot</groupId>
50             <artifactId>spring-boot-starter-tomcat</artifactId>
51             <scope>provided</scope>
52         </dependency>
53         <dependency>
54             <groupId>org.springframework.boot</groupId>
55             <artifactId>spring-boot-starter-test</artifactId>
56             <scope>test</scope>
57         </dependency>
58         <dependency>
59             <groupId>org.springframework.boot</groupId>
60             <artifactId>spring-boot-devtools</artifactId>
61             <optional>true</optional>
62         </dependency>
63                 <dependency>
64             <groupId>org.springframework.boot</groupId>
65             <artifactId>spring-boot-starter-jdbc</artifactId>
66         </dependency>
67         <dependency>
68             <groupId>org.mybatis.spring.boot</groupId>
69             <artifactId>mybatis-spring-boot-starter</artifactId>
70             <version>1.3.2</version>
71         </dependency>
72         <dependency>
73             <groupId>mysql</groupId>
74             <artifactId>mysql-connector-java</artifactId>
75             <scope>runtime</scope>
76         </dependency>
78     </dependencies>
80     <build>
81         <plugins>
82             <plugin>
83                 <groupId>org.springframework.boot</groupId>
84                 <artifactId>spring-boot-maven-plugin</artifactId>
85             </plugin>
86            <plugin>
87                  <groupId>org.apache.maven.plugins</groupId>
88                  <artifactId>maven-compiler-plugin</artifactId>
89                  <version>3.1</version>
90                  <configuration>
91                      <source>1.8</source>     
92                      <target>1.8</target>     
93                  </configuration>
94            </plugin>
95         </plugins>
96     </build>
98 </project>


Modification 1: first, the parent class depends on the version number, which is changed from 2.0.1 to 1.5.6 according to Baidu

  Modification 2: again, the error of importing JSP dependency: missing artifact org.apache.tomcat.embedded: Tomcat embedded Jasper: jar: 8.5.16

If you don’t add a JSP dependency, you can download the JSP file directly and report an error if you add it. Now I’m confused

Record it, there is a great God answer is more desirable

October 10, 2019 has been solved:

Finally, it was found that there was a problem with the version. It was tested from 1.5.6 to 2.0.3. It was found that there was no problem with the version 2.0.3, which proved that this version was suitable for my computer and my eclipse

Operating system: win10 64 bit
Eclipse: Version: 2019-09 R (4.13.0)
Maven should be 3.5.0

1. The following are the dependencies required by JSP :

    <!--servlet begin -->
    <!--servlet end -->
    <!--jsp begin -->
    <!--jsp end -->


2. Add the prefix in application.yml

        prefix: /WEB-INF/views
        suffix: .jsp

—-Encourage with you

[Solved] Springboot Error: invalid bound statement (not found)

1. Overview

An error is reported after springboot starts the web project

invalid bound statement (not found):xxx

2. Problem analysis

This is a very common exception. Error reporting usually includes the following situations:

2.1 syntax error

Mapper.xml does not correspond to Dao correctly

Java Dao interface

public void delete(@Param("id") String id);

Mapper.xml file corresponding to Java

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="xxx.xxx.xxx.xxDao">
    <!-- Delete -->
    <delete id="delete" parameterType="java.lang.String">
        DELETE FROM xxx WHERE id=#{id}

Check and confirm:

a) Whether the interface method name delete is consistent with the id = “delete” in XML

b) Whether the namespace = “XXX. XXX. XXX. Xxxdao” in the XML file is consistent with the path of the interface file (click whether to jump to the corresponding interface class)


c) Whether parametertype and resulttype (resultmap) are accurate

2.2 compilation error

Check whether the corresponding mapper.xml file exists under the project target \ classes \ path

If it does not exist, add it in pom.xml


Recompile and the corresponding XML file will appear (if you want to copy the XML, properties and other configuration files under Src/main/Java to the classes directory, add the above configuration)

two point three   Configuration error

There is a problem with the configuration path when specifying the scan package (mybatis. Mapper locations = classpath *:/XX/XX/mapper/*. XML) in the configuration file


An error occurs when springboot sets the log level [How to Solve]

Configure the springboot log. The output level is info. An error is reported when running:

Caused by: org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'logging.level' to java.util.Map<java.lang.String, java.lang.String>
    at org.springframework.boot.context.properties.bind.Binder.handleBindError(Binder.java:250)
    at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:226)
    at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:210)
    at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:166)
    at org.springframework.boot.context.logging.LoggingApplicationListener.setLogLevels(LoggingApplicationListener.java:307)
    at org.springframework.boot.context.logging.LoggingApplicationListener.initializeFinalLoggingLevels(LoggingApplicationListener.java:290)
    at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:238)
    at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:200)
    at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:173)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:74)

The application.yml file is configured as follows:


    console: "%d - %msg%n" #     Define the format of the log to be printed
# dateformat: # Set the log date format
# file: # Defines the log format for output to the log file
# config: # The location of the logging configuration file. For example, classpath:logback.xml.
  file: E:/sell/sell.log # Set the log file where the logs are saved
# max-history:
# max-size: # Set the maximum size of the log file # Set the log level
# path:/# location of the log file, e.g. /var/log
  register-shutdown-hook: false # Register a shutdown hook for the logging system when it is initialized.
  level: info

The reason is that the log level is configured incorrectly. It should be configured as

    root: info

The reasons are as follows:

Find the logging log level configuration shown in the following figure in the official document. The official address is: https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot -Features custom log levels

roughly means that we can use trace,   DEBUG,   INFO,   WARN,   ERROR,   FATAL,   perhaps   Off to specify the spring project log level. Its format is:
logging. Level. < logger-name>=< level>
therefore, we need to configure a logger name when configuring the log level, so we can specify a root or a package path as shown in the figure above. Configuring logging. Level. Root = warn means configuring the root logger, so the following configuration ideas are:
logging. Level. Root = warn
The configuration of logging. Level. Org. Hibernate = error
is that org.springframework.web is the debug level, org.hibernate is the error level, and the log output level of other projects is warn


Springboot about the error report of findone() method in springdatajpa

Problem Description:

First, using the 1.11 version of spring data JPA, you can use the findone () method to query by ID

Then I used version 2.0.5 and found that the findone() method reported an error and could not be used to query by ID

When the findbyid (ID) is used for query and the page uses thymeleaf to receive the data from the controller, the page reception fails


Use findById(id).get() to perform the query.