spring的main⽅法启动在main⽅法内调⽤SpringApplication.run。
⽰例:
HelloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@SpringBootApplication
public class UseMyStarterApplication {
spring framework面试题@Autowired
private HelloService helloService;
@RequestMapping("/")
public String index(){
return helloService.sayHello();
}
public static void main(String[] args) {
SpringApplication.run(UseMyStarterApplication.class, args);
}
}

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。