简单几步,在Eclipse中创建一个新的spring Boot项目:
1、Eclipse中安装STS插件:
Help -> Eclipse Marketplace...
Search或选择“Popular”标签,选择Spring Tool Suite (STS) for Eclipse插件,安装:
2、New -> Project...
找到Spring目录,选择Spring Starter Project,Next
3、填写跟项目相关的各种信息,然后Next:
4、选择需要的Dependency,然后Next:
5、Next,然后Finsh,新项目就创建好了,各个目录如下:
6、右键MySpringBootApplication中的main方法,Run As -> Spring Boot App,项目就可以启动了。
[java] view plain copy print?
package com.xjj;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class MySpringBootApplication {
public static void main(String[] args) {
SpringApplication.run(MySpringBootApplication.class, args);
}
}
package com.xjj;
import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication public class MySpringBootApplication {
public static void main(String\[\] args) {
SpringApplication.run(MySpringBootApplication.class, args);
}
}
由于选择了web dependency默认启动一个Tomcat,8080端口监听
7、把application.properties改名为application.yml(个人喜欢),修改Tomcat的启动端口:
[plain] view plain copy print?
- server:
- port: 8081
server: port: 8081