Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading multiple entity scan packages in spring boot application

I have Spring boot application

@SpringBootApplication
@EntityScan(basePackages = {"${scan.packages}"})
public class MyApplication {

    public static void main(String[] args) {
        SpringApplication.run(MyApplication.class, args);
    }

While reading multiple entity scan packages from one property separated by comma like below?

scan.packages=com.mycompany.model.package1 , com.mycompany.model.package2

I got this exception :

java.lang.IllegalArgumentException: Unknown entity: com.mycompany.model.package2.Myclass

like image 682
Elsayed Avatar asked Mar 27 '19 09:03

Elsayed


1 Answers

You can scan multiple Entity like this

@EntityScan(basePackages= {"scan.packages1","scan.packages2"})
like image 158
Devratna Avatar answered Nov 17 '22 19:11

Devratna