Tag Archives: spring boot

How to Solve Swagger Always Displays “basic-error-controller” Issue

The main reason is that the controller is not scanned in the swagger configuration, Here is the solution below:

public Docket createRestApi(){
    return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
                .build();
}

apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))

Indicates that swagger will scan the interface with @API.

Done!

[Solved] seata:Error creating bean with name ‘globalTransactionScanner‘ defined in class path resource

Error Description:

Cause: my idea uses jdk17 by default. In jdk17, many classes are discarded or deleted. You can switch to jdk8

An error occurred during spring integration of Seata. The error is as follows:


Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-08-09 14:03:16.565 ERROR 15912 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'globalTransactionScanner' defined in class path resource [io/seata/spring/boot/autoconfigure/SeataAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.seata.spring.annotation.GlobalTransactionScanner]: Factory method 'globalTransactionScanner' threw exception; nested exception is java.lang.ExceptionInInitializerError
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658) ~[spring-beans-5.3.22.jar:5.3.22]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638) ~[spring-beans-5.3.22.jar:5.3.22]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-5.3.22.jar:5.3.22]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) ~[spring-beans-5.3.22.jar:5.3.22]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.22.jar:5.3.22]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.22.jar:5.3.22]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.22.jar:5.3.22]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.22.jar:5.3.22]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.22.jar:5.3.22]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213) ~[spring-beans-5.3.22.jar:5.3.22]
	at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:258) ~[spring-context-5.3.22.jar:5.3.22]
	at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:762) ~[spring-context-5.3.22.jar:5.3.22]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:567) ~[spring-context-5.3.22.jar:5.3.22]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.2.jar:2.7.2]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[spring-boot-2.7.2.jar:2.7.2]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) ~[spring-boot-2.7.2.jar:2.7.2]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-2.7.2.jar:2.7.2]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-2.7.2.jar:2.7.2]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[spring-boot-2.7.2.jar:2.7.2]
	at com.xs.ProtocolApplication.main(ProtocolApplication.java:17) ~[classes/:na]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.seata.spring.annotation.GlobalTransactionScanner]: Factory method 'globalTransactionScanner' threw exception; nested exception is java.lang.ExceptionInInitializerError
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.3.22.jar:5.3.22]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ~[spring-beans-5.3.22.jar:5.3.22]
	... 19 common frames omitted
Caused by: java.lang.ExceptionInInitializerError: null
	at net.sf.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:166) ~[cglib-3.1.jar:na]
	at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25) ~[cglib-3.1.jar:na]
	at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216) ~[cglib-3.1.jar:na]
	at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:144) ~[cglib-3.1.jar:na]
	at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:116) ~[cglib-3.1.jar:na]
	at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108) ~[cglib-3.1.jar:na]
	at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104) ~[cglib-3.1.jar:na]
	at net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:69) ~[cglib-3.1.jar:na]
	at io.seata.config.ConfigurationCache.proxy(ConfigurationCache.java:104) ~[seata-all-1.5.1.jar:1.5.1]
	at io.seata.config.ConfigurationFactory.buildConfiguration(ConfigurationFactory.java:138) ~[seata-all-1.5.1.jar:1.5.1]
	at io.seata.config.ConfigurationFactory.getInstance(ConfigurationFactory.java:94) ~[seata-all-1.5.1.jar:1.5.1]
	at io.seata.spring.annotation.GlobalTransactionScanner.<init>(GlobalTransactionScanner.java:105) ~[seata-all-1.5.1.jar:1.5.1]
	at io.seata.spring.annotation.GlobalTransactionScanner.<init>(GlobalTransactionScanner.java:162) ~[seata-all-1.5.1.jar:1.5.1]
	at io.seata.spring.boot.autoconfigure.SeataAutoConfiguration.globalTransactionScanner(SeataAutoConfiguration.java:83) ~[seata-spring-boot-starter-1.5.1.jar:1.5.1]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.22.jar:5.3.22]
	... 20 common frames omitted
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @710f4dc7
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354) ~[na:na]
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297) ~[na:na]
	at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199) ~[na:na]
	at java.base/java.lang.reflect.Method.setAccessible(Method.java:193) ~[na:na]
	at net.sf.cglib.core.ReflectUtils$2.run(ReflectUtils.java:56) ~[cglib-3.1.jar:na]
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:318) ~[na:na]
	at net.sf.cglib.core.ReflectUtils.<clinit>(ReflectUtils.java:46) ~[cglib-3.1.jar:na]
	... 39 common frames omitted

2022-08-09 14:03:16.566  WARN 15912 --- [       Thread-1] c.a.n.common.http.HttpClientBeanHolder   : [HttpClientBeanHolder] Start destroying common HttpClient
2022-08-09 14:03:16.567  WARN 15912 --- [       Thread-5] c.a.nacos.common.notify.NotifyCenter     : [NotifyCenter] Start destroying Publisher
2022-08-09 14:03:16.567  WARN 15912 --- [       Thread-5] c.a.nacos.common.notify.NotifyCenter     : [NotifyCenter] Destruction of the end
2022-08-09 14:03:16.567  WARN 15912 --- [       Thread-1] c.a.n.common.http.HttpClientBeanHolder   : [HttpClientBeanHolder] Destruction of the end

Solution

Reason: the class globalTransactionScanner cannot be found and cannot be initialized.

Solution: I use JDK 17 in my IDEA. It’s OK to switch to JDK 8.

[Solved] Springboot Reflection calls ServiceImpl Error: java.lang.NullPointerException, mapper is null

Springboot uses reflection to call serviceimpl and reports an error: java.lang.nullpointerexception

Because the mapper of ServiceImpl is null, the following is the original implementation code:

           // package name and class name
           Class classzz = Class.forName("com.XXX.XXX.service.impl.SenDataServiceImpl");

           // Get the constructor object
           Constructor constructor = null;
           try {
               constructor = classzz.getConstructor();
           } catch (NoSuchMethodException e) {
               e.printStackTrace();
           }
           // Create an object using the constructor object
           Object o = constructor.newInstance();
           // Pass the method to be executed Pass the parameter type, if not, you can leave it out
           Method method = classzz.getMethod("method name", long.class,String.class,String.class );
// invoke method, and pass parameters, if there are no parameters, you can leave them out
           Object obj =method.invoke(o,  5,
                  "param1",
                   "param2");

In the post query mode, you need to ContextLoader.getCurrentWebApplicationContext() firstly, but you haven’t gone to invoke, so the ContextLoader.getCurrentWebApplicationContext() is null.

The final solution is as follows:

1. Create a new class SpringBootBeanUtil

package com.smart.hyd.common.utils.reflect;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * SpringBoot Common class to get the bean tool class in the Spring container
 */
@Component
public class SpringBootBeanUtil implements ApplicationContextAware {

    private static ApplicationContext applicationContext;

    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        if (SpringBootBeanUtil.applicationContext == null) {
            SpringBootBeanUtil.applicationContext = applicationContext;
        }
        System.out.println("========ApplicationContext========");
//        System.out.println("========In the general class you can get the applicationContext object by calling SpringBootBeanUtil.getApplicationContext()========");
        System.out.println("========applicationContext="+ SpringBootBeanUtil.applicationContext +"========");
    }

    /**
     * get applicationContext
     * @return
     */
    public static ApplicationContext getApplicationContext() {
        return applicationContext;
    }

    /**
     * Get Bean by name.
     * @param name
     * @return
     */
    public static Object getBean(String name) {
        return getApplicationContext().getBean(name);
    }

    /**
     * Get Bean by class.
     * @param clazz
     * @return
     */
    public static <T> T getBean(Class<T> clazz) {
        return getApplicationContext().getBean(clazz);
    }

    /**
     * Return the specified bean by name, and Clazz
     * @param name
     * @param clazz
     * @return
     */
    public static <T> T getBean(String name, Class<T> clazz) {
        return getApplicationContext().getBean(name, clazz);
    }

}

2. Call SpringBootBeanUtil.getApplicationContext(). When invoking, the first parameter is applicationContext.getBean(ServiceImplType). Refer to the following code for specific implementation.

try {
               //Retrieve the created object from the ApplicationContext
               // Do not create the serviceimpi object directly by reflection, because the object created by reflection cannot instantiate the dao interface
               ApplicationContext applicationContext = SpringBootBeanUtil.getApplicationContext();
               //reflection creates the serviceimpi entity object, and the entity class
               Class<? > ServiceImplType = Class.forName("com.XXX.XXX.service.impl.SenDataServiceImpl");
              // Class<? > entityType = Class.forName("com.XXX.XXX.service.impl.SenDataServiceImpl");
               //reflection set method parameters.
               Method method = ServiceImplType.getDeclaredMethod("methodName",long.class,String.class,String.class );
               // get the instantiated bean in the ApplicationContext according to class
               method.invoke(applicationContext.getBean(ServiceImplType), 5,
                           "param1",
                           "param2");

           } catch (ClassNotFoundException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
               e.printStackTrace();
               LOGGER.error("\n onMessage Receive Processing Message Failed - {}", "methodName");
           }

This solves the problem that the reflection calls ServiceImpland the mapper reports an error when it is null.

[Solved] SpringBoot Date Convert Error: JSON parse error: Cannot deserialize value of type `java.time.LocalDateTime`

1. When data of type localdate in Java is tested on swagger, the format when input in the format of json is 2018-07-09. It should be noted that 07 and 09 are two digits, not one digit.

2. If the date is of LocalDate type, JacksonAutoConfiguration will automatically process whether the foreground transmits the date in string format to the background or the background returns the date in format to the front end.

3. If the date is of LocalDateTime type, we need to process it from the front end to the back end and from the back end to the front end. Because the configuration in the following YML does not apply to Java 8 date types, such as LocalDate and LocalDateTime, it only applies to fields of date or DateTime type.

#Date Formatting
spring:
  jackson:
    date-format: yyyy-MM-dd HH:mm:ss

Solution: add LocalDateTimeConfig configuration class

/**
 * LocalDateTime
 */
@Configuration
public class LocalDateTimeGlobalConfig {
    private static final String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";

    /**
     *Configuring LocalDateTime type serialization and deserialization
     */
    @Bean
    public Jackson2ObjectMapperBuilderCustomizer jsonCustomizer() {
        /*return new Jackson2ObjectMapperBuilderCustomizer() {
            @Override
            public void customize(Jackson2ObjectMapperBuilder jacksonObjectMapperBuilder) {
                jacksonObjectMapperBuilder.serializers(new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(DATE_TIME_PATTERN)));
                jacksonObjectMapperBuilder.deserializers(new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern(DATE_TIME_PATTERN)));
            }
        };*/
        //This approach is equivalent to the above
        return builder -> {
            builder.serializers(new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(DATE_TIME_PATTERN)));
            builder.deserializers(new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern(DATE_TIME_PATTERN)));
        };
    }
}

[Solved] Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource could

An error occurred when starting the springboot server

Error prompt:

Description:

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


Action:

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).

Solution:

This is a dependency issue, using druid’s data pool to configure the database parameters and not importing druid’s package in pom.xml.

<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.23</version>
</dependency>

 

Mybatis-Plus logical delete mapping error [How to Solve]

The error reports are as follows: has been unable to understand why there is a pile of garbled code in my SQL. It has always been thought that there is an error in my own usage or configuration

But I didn’t find any problems after consulting the MP manual

Until you suddenly wake up, it may be a configuration problem

Because I use application.properties but the manual use yml, there are certain format problems

Official website:

My:

Move the comment to a place other than the statement and start successfully

 

How to Solve Spring Boot Maven Build Error

Error 1:

[ERROR]Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.21.0:test (default-test) on project motherBuyBoot: There are test failures.
[ERROR] Please refer to D:\web\motherbuy\target\surefire-reports for the individual test results. [ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.

Solution:

the pom.xml file has the wrong version of Junit, or for some other reason, the junit dependency is commented out and the compilation passes.

 

Error 2:

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project motherBuyBoot: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

Solution:

Method: Compile compile environment problems, that are not configured; see the screenshot below to solve, do not forget to update maven.

[Solved] Failed to start bean ‘documentationPluginsBootstrapper’; nested exception is java.lang.NullPointerException

# org.springframework.context.ApplicationContextException: Failed to start bean ‘documentationPluginsBootstrapper’; nested exception is java.lang.NullPointerException

First, The relevant configurations in my pom.xml are as follows

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.1</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <dependencies>
        <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>

        <!--swagger-->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.9.2</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.9.2</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

At this point, my spring-boot-starter version may not match the swagger version, and the following error is reported

org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException

Because Springfox uses path matching based on AntPathMatcher, while Spring Boot 2.6.X uses PathPatternMatcher.

Solution:

Configurate in application.properties:

spring.mvc.pathmatch.matching-strategy=ANT_PATH_MATCHER

The problem can be solved.

[Solved] nested exception is org.flowable.common.engine.api.FlowableException: Error initialising dmn data mo

FactoryBean threw exception on object creation; nested exception is org.flowable.common.engine.api.FlowableException: Error initialising dmn data model

The following error is reported when starting a project inherited from Flowable and Spring Boot:

05.824 INFO  o.f.s.SpringProcessEngineConfiguration:922  main                    Executing configure() of class org.flowable.dmn.spring.configurator.SpringDmnEngineConfigurator (priority:200000)
09.818 INFO  liquibase.lockservice         :26   main                    Waiting for changelog lock....
19.821 INFO  liquibase.lockservice         :26   main                    Waiting for changelog lock....
29.825 INFO  liquibase.lockservice         :26   main                    Waiting for changelog lock....
39.835 INFO  liquibase.lockservice         :26   main                    Waiting for changelog lock....
49.851 INFO  liquibase.lockservice         :26   main                    Waiting for changelog lock....
59.859 INFO  liquibase.lockservice         :26   main                    Waiting for changelog lock....
09.864 INFO  liquibase.lockservice         :26   main                    Waiting for changelog lock....
19.879 INFO  liquibase.lockservice         :26   main                    Waiting for changelog lock....
29.894 INFO  liquibase.lockservice         :26   main                    Waiting for changelog lock....
39.907 INFO  liquibase.lockservice         :26   main                    Waiting for changelog lock....
49.911 INFO  liquibase.lockservice         :26   main                    Waiting for changelog lock....
59.930 INFO  liquibase.lockservice         :26   main                    Waiting for changelog lock....
09.939 INFO  liquibase.lockservice         :26   main                    Waiting for changelog lock....
19.944 INFO  liquibase.lockservice         :26   main                    Waiting for changelog lock....
29.966 INFO  liquibase.lockservice         :26   main                    Waiting for changelog lock....
39.975 INFO  liquibase.lockservice         :26   main                    Waiting for changelog lock....
49.989 INFO  liquibase.lockservice         :26   main                    Waiting for changelog lock....
00.000 INFO  liquibase.lockservice         :26   main                    Waiting for changelog lock....
10.013 INFO  liquibase.lockservice         :26   main                    Waiting for changelog lock....
20.022 INFO  liquibase.lockservice         :26   main                    Waiting for changelog lock....
30.035 INFO  liquibase.lockservice         :26   main                    Waiting for changelog lock....
40.052 INFO  liquibase.lockservice         :26   main                    Waiting for changelog lock....
50.058 INFO  liquibase.lockservice         :26   main                    Waiting for changelog lock....
00.065 INFO  liquibase.lockservice         :26   main                    Waiting for changelog lock....
10.075 INFO  liquibase.lockservice         :26   main                    Waiting for changelog lock....
20.078 INFO  liquibase.lockservice         :26   main                    Waiting for changelog lock....
30.097 INFO  liquibase.lockservice         :26   main                    Waiting for changelog lock....
40.114 INFO  liquibase.lockservice         :26   main                    Waiting for changelog lock....
50.129 INFO  liquibase.lockservice         :26   main                    Waiting for changelog lock....
00.142 INFO  liquibase.lockservice         :26   main                    Waiting for changelog lock....
10.377 WARN  o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext:591  main                    Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'appletLeaveController': Unsatisfied dependency expressed through field 'leaveService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'appletLeaveServiceImpl': Unsatisfied dependency expressed through field 'flowableProcessInstanceService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'flowableProcessInstanceServiceImpl': Unsatisfied dependency expressed through field 'historyService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'historyServiceBean' defined in class path resource [org/flowable/spring/boot/ProcessEngineServicesAutoConfiguration.class]: Unsatisfied dependency expressed through method 'historyServiceBean' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'processEngine': FactoryBean threw exception on object creation; nested exception is org.flowable.common.engine.api.FlowableException: Error initialising dmn data model
10.572 INFO  c.a.druid.pool.DruidDataSource:2071 main                    {dataSource-1} closing ...
10.638 INFO  c.a.druid.pool.DruidDataSource:2144 main                    {dataSource-1} closed
10.697 INFO  o.a.c.core.StandardService    :173  main                    Stopping service [Tomcat]
10.981 ERROR o.s.boot.SpringApplication    :830  main                    Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'appletLeaveController': Unsatisfied dependency expressed through field 'leaveService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'appletLeaveServiceImpl': Unsatisfied dependency expressed through field 'flowableProcessInstanceService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'flowableProcessInstanceServiceImpl': Unsatisfied dependency expressed through field 'historyService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'historyServiceBean' defined in class path resource [org/flowable/spring/boot/ProcessEngineServicesAutoConfiguration.class]: Unsatisfied dependency expressed through method 'historyServiceBean' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'processEngine': FactoryBean threw exception on object creation; nested exception is org.flowable.common.engine.api.FlowableException: Error initialising dmn data model
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:659)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:639)
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1431)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:740)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:415)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
	at com.sinosoft.MobileAppletBusinessApplication.main(MobileAppletBusinessApplication.java:32)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'appletLeaveServiceImpl': Unsatisfied dependency expressed through field 'flowableProcessInstanceService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'flowableProcessInstanceServiceImpl': Unsatisfied dependency expressed through field 'historyService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'historyServiceBean' defined in class path resource [org/flowable/spring/boot/ProcessEngineServicesAutoConfiguration.class]: Unsatisfied dependency expressed through method 'historyServiceBean' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'processEngine': FactoryBean threw exception on object creation; nested exception is org.flowable.common.engine.api.FlowableException: Error initialising dmn data model
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:659)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:639)
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1431)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1389)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1309)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:656)
	... 18 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'flowableProcessInstanceServiceImpl': Unsatisfied dependency expressed through field 'historyService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'historyServiceBean' defined in class path resource [org/flowable/spring/boot/ProcessEngineServicesAutoConfiguration.class]: Unsatisfied dependency expressed through method 'historyServiceBean' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'processEngine': FactoryBean threw exception on object creation; nested exception is org.flowable.common.engine.api.FlowableException: Error initialising dmn data model
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:659)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:639)
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1431)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1389)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1309)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:656)
	... 32 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'historyServiceBean' defined in class path resource [org/flowable/spring/boot/ProcessEngineServicesAutoConfiguration.class]: Unsatisfied dependency expressed through method 'historyServiceBean' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'processEngine': FactoryBean threw exception on object creation; nested exception is org.flowable.common.engine.api.FlowableException: Error initialising dmn data model
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:541)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1389)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1309)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:656)
	... 46 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'processEngine': FactoryBean threw exception on object creation; nested exception is org.flowable.common.engine.api.FlowableException: Error initialising dmn data model
	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:176)
	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:101)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1884)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getObjectForBeanInstance(AbstractAutowireCapableBeanFactory.java:1284)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:345)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1389)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1309)
	at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887)
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791)
	... 59 common frames omitted
Caused by: org.flowable.common.engine.api.FlowableException: Error initialising dmn data model
	at org.flowable.common.engine.impl.db.LiquibaseBasedSchemaManager.initSchema(LiquibaseBasedSchemaManager.java:68)
	at org.flowable.dmn.engine.impl.db.DmnDbSchemaManager.initSchema(DmnDbSchemaManager.java:36)
	at org.flowable.dmn.engine.impl.cmd.SchemaOperationsDmnEngineBuild.execute(SchemaOperationsDmnEngineBuild.java:27)
	at org.flowable.dmn.engine.impl.cmd.SchemaOperationsDmnEngineBuild.execute(SchemaOperationsDmnEngineBuild.java:23)
	at org.flowable.common.engine.impl.interceptor.DefaultCommandInvoker.execute(DefaultCommandInvoker.java:22)
	at org.flowable.common.engine.impl.interceptor.TransactionContextInterceptor.execute(TransactionContextInterceptor.java:53)
	at org.flowable.common.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:72)
	at org.flowable.common.spring.SpringTransactionInterceptor.lambda$execute$0(SpringTransactionInterceptor.java:56)
	at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140)
	at org.flowable.common.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:56)
	at org.flowable.common.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30)
	at org.flowable.common.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:56)
	at org.flowable.dmn.engine.impl.DmnEngineImpl.<init>(DmnEngineImpl.java:48)
	at org.flowable.dmn.engine.DmnEngineConfiguration.buildDmnEngine(DmnEngineConfiguration.java:217)
	at org.flowable.dmn.spring.SpringDmnEngineConfiguration.buildDmnEngine(SpringDmnEngineConfiguration.java:69)
	at org.flowable.dmn.spring.configurator.SpringDmnEngineConfigurator.initDmnEngine(SpringDmnEngineConfigurator.java:68)
	at org.flowable.dmn.spring.configurator.SpringDmnEngineConfigurator.configure(SpringDmnEngineConfigurator.java:57)
	at org.flowable.common.engine.impl.AbstractEngineConfiguration.configuratorsAfterInit(AbstractEngineConfiguration.java:923)
	at org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl.init(ProcessEngineConfigurationImpl.java:1016)
	at org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl.buildProcessEngine(ProcessEngineConfigurationImpl.java:915)
	at org.flowable.spring.SpringProcessEngineConfiguration.buildProcessEngine(SpringProcessEngineConfiguration.java:72)
	at org.flowable.spring.ProcessEngineFactoryBean.getObject(ProcessEngineFactoryBean.java:60)
	at org.flowable.spring.ProcessEngineFactoryBean.getObject(ProcessEngineFactoryBean.java:32)
	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:169)
	... 69 common frames omitted
Caused by: org.flowable.common.engine.api.FlowableException: Error updating dmn engine tables
	at org.flowable.common.engine.impl.db.LiquibaseBasedSchemaManager.schemaUpdate(LiquibaseBasedSchemaManager.java:105)
	at org.flowable.common.engine.impl.db.LiquibaseBasedSchemaManager.initSchema(LiquibaseBasedSchemaManager.java:61)
	... 92 common frames omitted
Caused by: liquibase.exception.LockException: Could not acquire change log lock.  Currently locked by DESKTOP-T9LSH1H (192.168.1.108) since 22-6-15 上午9:27
	at liquibase.lockservice.StandardLockService.waitForLock(StandardLockService.java:234)
	at liquibase.Liquibase.lambda$update$1(Liquibase.java:214)
	at liquibase.Scope.lambda$child$0(Scope.java:177)
	at liquibase.Scope.child(Scope.java:186)
	at liquibase.Scope.child(Scope.java:176)
	at liquibase.Scope.child(Scope.java:155)
	at liquibase.Liquibase.runInScope(Liquibase.java:2404)
	at liquibase.Liquibase.update(Liquibase.java:211)
	at liquibase.Liquibase.update(Liquibase.java:197)
	at liquibase.Liquibase.update(Liquibase.java:193)
	at liquibase.Liquibase.update(Liquibase.java:185)
	at org.flowable.common.engine.impl.db.LiquibaseBasedSchemaManager.schemaUpdate(LiquibaseBasedSchemaManager.java:103)
	... 93 common frames omitted

Process finished with exit code 1

After investigation, it was found that the problem was MySQL

Solution: find a table whose table name is suffixed with databasechangeloglock and change it to the format shown in the following figure to solve the problem

Note: all tables suffixed with databasechangeloglock should be checked

[Solved] ApplicationContextException: Failed to start bean ‘documentationPluginsBootstrapper‘;

ApplicationContextException: Failed to start bean ‘documentationPluginsBootstrapper‘;

Spring boot reports the following errors:

org.springframework.context.applicationContextException: Failed to start bean ‘documentationPluginsBootstrapper’; nested exception is java. lang.NullPointerException

After testing for a long time, it is found that the reason for swagger2:

Version 3.0.0 was originally used:

<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 -->
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>3.0.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui -->
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger-ui</artifactId>
    <version>3.0.0</version>
</dependency>

It is said that:

Reason: This is because Springfox uses path matching based on AntPathMatcher, while Spring Boot 2.6.X uses PathPatternMatcher.
Solution: Configure in application.properties: spring.mvc.pathmatch.matching-strategy=ANT_PATH_MATCHER

After testing, no error was reported, but the search access http://localhost:8080/swagger-ui.html has 404

Final solution:

Switch the version of swagger2 and swaggerui to version 2.9.2

<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 -->
<dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger2</artifactId>
        <version>2.9.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui -->
<dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger-ui</artifactId>
        <version>2.9.2</version>
</dependency>

If it does not work like me, just add the following code in application.properties:

spring.mvc.pathmatch.matching-strategy=ANT_PATH_MATCHER

Problem solved!

[Solved] Springboot integrate swagger error: Failed to start bean ‘documentationPluginsBootstrapper‘

spring boot upgrade to 2.6.x+ version, I suddenly found the following error when integrating with swagger:

org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException

Reason: because the path matching used by springfox is based on AntPathMatcher, and spring boot 2.6.X uses PathPatternMatcher, which can change the matching rules

Solution:
add the following configuration in the configuration file (application.yaml)

spring:
  mvc:
    pathmatch:
      matching-strategy: ant_path_matcher

[Solved] Springboot error: Could Not Found xxmapper

springboot error: could not found xxmapper

Error Messages:

Unsatisfied dependency expressed through field ‘baseMapper’; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.xxxx.server.mapper.AdminMapper’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

 

 

Solution: Add mapper package scan to springboot startup class

@MapperScan("com.xxxx.server.mapper")