package com.sf; import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.ComponentScan; // @SpringBootApplication是springboot提供的注解 // 标志一个类是 springboot的应用程序的主函数入口 // 默认扫描路径是当前类所在的路径 以及子路径 当前项目中的“com.sf” @SpringBootApplication //@ComponentScan("com.hello") //@ComponentScan("com.sf") @MapperScan("com.sf.mapper") // 如果不希望每次都在Mapper类上增加@Mapper 可以使用包扫描注解 public class DemoApplication { public static void main(String[] args) { // SpringApplication类执行了run方法 传递了DemoApplication.class和args两个参数 // SpringApplication是一个spring帮我们启动应用程序的类 通过run方法来启动 // 启动所需要的参数 是DemoApplication.class 还有 main函数的参数 // Hello.java -> javac Hello.java -> Hello.class // java Hello 1 2 args={1,2} // 接收启动时传进来的参数 spring也支持一些指定参数的传递 SpringApplication.run(DemoApplication.class, args); } }