How to do multi-project public configuration in springboot

I have multiple spring boot projects, and I want to extract the common code and configuration of these projects into a common configuration. For example,

@EnableAspectJAutoProxy
public class DefaultConfig {}

I want all projects to open AOP, but I don"t want every project to copy such a code. What should I do to make multiple projects share a single code?

Mar.22,2021

you first write a DefaultConfig class, and then you have @ Import (xxpackage.DefaultConfig) in each project.


I found a more elegant solution: customize a spring-boot-start

@EnableAspectJAutoProxy
@Configuration
public class DefaultConfig {}

then add

to spring.factories
org.springframework.boot.autoconfigure.EnableAutoConfiguration=xxxx.xxx.DefaultConfig

finally, you can package and publish it in maven.

each project only needs to add this maven dependency without intruding into any Java code.

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-1e96d33-68d7c.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-1e96d33-68d7c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?