|
@@ -1,8 +1,14 @@
|
|
|
package com.sf;
|
|
|
|
|
|
+import com.sf.config.FoodConfig;
|
|
|
+import com.sf.config.VegetablesConfig;
|
|
|
import org.mybatis.spring.annotation.MapperScan;
|
|
|
+import org.springframework.boot.ApplicationArguments;
|
|
|
+import org.springframework.boot.ApplicationRunner;
|
|
|
+import org.springframework.boot.CommandLineRunner;
|
|
|
import org.springframework.boot.SpringApplication;
|
|
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
|
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
|
import org.springframework.context.annotation.ComponentScan;
|
|
|
|
|
|
// @SpringBootApplication是springboot提供的注解
|
|
@@ -11,8 +17,10 @@ import org.springframework.context.annotation.ComponentScan;
|
|
|
@SpringBootApplication
|
|
|
//@ComponentScan("com.hello")
|
|
|
//@ComponentScan("com.sf")
|
|
|
-@MapperScan("com.sf.mapper") // 如果不希望每次都在Mapper类上增加@Mapper 可以使用包扫描注解
|
|
|
-public class DemoApplication {
|
|
|
+//@MapperScan("com.sf.mapper") // 如果不希望每次都在Mapper类上增加@Mapper 可以使用包扫描注解
|
|
|
+@EnableConfigurationProperties({FoodConfig.class}) //打开对配置文件的自定义使用 接收的类是FoodConfig
|
|
|
+//public class DemoApplication implements ApplicationRunner {
|
|
|
+public class DemoApplication implements CommandLineRunner {
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
// SpringApplication类执行了run方法 传递了DemoApplication.class和args两个参数
|
|
@@ -24,4 +32,14 @@ public class DemoApplication {
|
|
|
SpringApplication.run(DemoApplication.class, args);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void run(String... args) throws Exception {
|
|
|
+ System.out.println("项目启动啦!!!!!");
|
|
|
+ }
|
|
|
+
|
|
|
+// @Override
|
|
|
+// public void run(ApplicationArguments args) throws Exception {
|
|
|
+// System.out.println("项目启动啦!!!!!");
|
|
|
+// }
|
|
|
+
|
|
|
}
|