Spring boot (3)---Custom Spring boot starter Issues

Source: Internet
Author: User

1. "Failed to process import candidates for configuration class [Com.simple ...]":

Main reasons:

This is because your custom starter is packaged with Spring-boot-maven-plugin, which is configured in the Pom.xml of your custom starter project:

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

This type of package, is based on the spring boot packaging, classpath settings, relative directory, resource directory, and so on. When you use this custom starter jar package with another spring boot project. There will be problems because you think that this starter is an ordinary jar package.

This will not find your class definition.

Workaround:

Remove the packaged plug-in settings from the Pom.xml in the custom starter, using the default Jar wrapping method. can solve this problem.

2." java.lang.IllegalArgumentException: Not an managed type: class .... ”

Root cause:

Some of the JPA, entities, and repository classes you use are not the directories where your spring boot boot files are located. Causes JPA to search for these entities, the Repository class.

Workaround:

Add the following annotations to the start class of Spring boot:

@EnableJpaRepositories ("com.example.repository")//The package paths of JPA-related entities and repository that are not searchable

@EntityScan ("Com.example.repository")

If you use the MONGO JPA you should also add the corresponding.

@EnableMongoRepositories ("Com.example.mongo")
@EnableJpaRepositories ("Com.example.repository")

@EntityScan ("Com.example.repository")

Spring boot (3)---Custom Spring boot starter Issues

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.