Springboot type conversion exceptions caused by using Devtools

Source: Internet
Author: User

  • Problems encountered:
    Springboot the heat deployment in the project raises the lesson of the blood, error code location:

      1new XStream ();   2 xstream1.autodetectannotations (true);   3 xstream1.alias ("interboss", Interbossheader.  Class);   4 Interbossheader resp = (interbossheader) xstream1.fromxml (response);
    The POM configuration in the project:

    1 <Dependency>2     <groupId>Org.springframework.boot</groupId>3     <Artifactid>Spring-boot-devtools</Artifactid>4     <Scope>Runtime</Scope>5 </dependency>
  • Analysis of the problem:
    The above configuration found that the same type (Interbossheader) unexpectedly occurred type conversion exception! wqnmmp-. —
    In order to implement a class loader to load the class that will change in the project, Spring's Dev-tools implements a classloader for the classloader of the different types of conversion exceptions, so that the new changes will be updated in the event of a reboot. In fact, there are some official documents in the description:

    1By default, any open project in your IDE would be loaded using the2"Restart" ClassLoader, and any regular. jar file would be loaded using3The "base" ClassLoader. If you work in a multi-module project, and not4Each module was imported into the your IDE, you could need to customize5Things. To does this can create a6Meta-inf/spring-devtools.properties file.7The Spring-devtools.properties file can contain restart.exclude. and8Restart.include. Prefixed properties. The Include elements are items9That should is pulled up into the "restart" ClassLoader, and theTenExclude elements is items that should is pushed down into the "base" OneClassLoader. The value of the property was a regex pattern that would be AApplied to the classpath.
  • Workaround:
    The first solution: Create the Meta_inf folder under the Resources directory, and then create the Spring-devtools.properties file with a configuration similar to the following:
    Restart.exclude.companycommonlibs=/mycorp-common-[\w-]+.jar
    Restart.include.projectcommon=/mycorp-myproj-[\w-]+.jar

    Second solution: Do not use Spring-boot-devtools (when I did not say)


Reference: Test water connection

Springboot type conversion exceptions caused by using Devtools

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.