这篇文章主要介绍了springboot自定义starter实现过程图解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
1、创建一个Empty Project
2、在该工程中点击+,选择new module,新建一个maven工程
点击确定。
3、在该工程中点击+,选择new module,新建一个Spring Initializr工程
后面直接默认next,然后点击finishi。
两个都创建完毕之后点击apply,点击OK。得到如下结构:
4、在gong-spring-boot-starter中引入gong-spring-boot-starter-autoconfigurer,即在gong-spring-boot-starter的pom.xml中
<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://.gong.starter.HelloService;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.web.bind.annotation.GetMapping;import org.springframework.web.bind.annotation.RestController;@RestControllerpublic class HelloController { @Autowired HelloService helloService; @GetMapping("/hello") public String hello(){ return helloService.sayHelloGong("haha"); }}启动服务器:
完美。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。