一、用代码硬搞
思路:
只要搭建一个maven应用,然后引用相应的pom即可。
步骤:
1、Intellij新建一个普通的maven应用
2、pom中填入如下内容:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.example</groupId> <artifactId>myproject</artifactId> <version>0.0.1-SNAPSHOT</version> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.2.RELEASE</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
注意:一个是spring-boot-starter-parent,一个是spring-boot-starter-web
3、运行命令:mvn spring-boot:run即可启动
参考资料:
备注:用上面这个框架,无法实现euraka client,因为死活不肯导入spring common这个jar
二、利用spring.io
比较简单,不详述了,参考下面2个文章。
注意到:windows下面的intellij最好用Intellij中嵌入的spring.io,而不是直接从官网下载的zip包,因为windows中用新建项目->已存在的项目,导进去后,将src搞丢了,不知道怎么回事。