同上创建service业务层
之后在启动类中,实现CommandLineRunner 接口之后重写run方法 、、、、 通过@Autowired注入业务层的实现类,之后在run方法中调用业务方法
@SpringBootApplication
public class Application implements CommandLineRunner {
@Autowired
private StudentService studentService;
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
//重写run方法
@Override
public void run(String... args) throws Exception {
//调用业务方法
String sayHallo = studentService.sayHello(" World");
System.out.println(sayHallo);
}
}