@ComponentScan({“ com.package1”})和scan.packages = com.package1有什么区别

时间:2019-03-06 13:37:08

标签: spring spring-boot annotations

 @SpringBootApplication(scanBasePackages={"com.package1"})
    public class SpringbootIn10StepsApplication {
        public static void main(String[] args) {
            ApplicationContext applicationContext =
                SpringApplication.run(SpringbootIn10StepsApplication.class, args);

        }
    }

application.properties scan.packages = com.package1

  @SpringBootApplication(scanBasePackages="${scan.packages}")
        public class SpringbootIn10StepsApplication {
            public static void main(String[] args) {
                ApplicationContext applicationContext =
                    SpringApplication.run(SpringbootIn10StepsApplication.class, args);

            }
        }

我提到了如何使用application.properties文件中可用的注释和属性扫描软件包。 我需要知道确切的区别是哪一个先加载? 我可以使用scan.packages属性添加多个软件包吗?

0 个答案:

没有答案