1. 程式人生 > >idea新建SpringBoot專案,具體到每個步驟

idea新建SpringBoot專案,具體到每個步驟

     當下,微服務的概念特別火,微服務框架簡直就是中小企業的福音,他的優點之一就是能夠快速搭建,大量減少人力和時間成本。目前最火的兩個微服務框架就是springboot和springcloud,下面就總結springboot專案的搭建,springboot的原理就不多說,個人理解這是一種伺服器的映象,就是你可以自己來選擇是什麼框架的映象,ssm啊ssh啊,都可以。

    springboot專案的一大優點就是幾乎沒有配置檔案(當然這是他的追求,其實還是要配置一些資訊的),下面就來介紹springboot專案的建立步驟:

我用的工具是IDEA:

1、

2、

3、

4、

5、

6、

7、

8、

9、

10、

11、

12、

13、

14、

15、

16、

17、

18、

19、

20、

附上pom.xml裡的配置:

<?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.tronsis</groupId>
   <artifactId>helloworld</artifactId>
   <version>0.0.1-SNAPSHOT</version>
   <packaging>war</packaging>

   <!-- 專案的名稱 -->
   <name>helloworld</name>
   <description>Demo project for Spring Boot</description>

   <!--  -->
   <parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>2.0.0.RELEASE</version>
      <relativePath/><!-- lookup parent from repository -->
   </parent>

   <!-- 配置檔案,編碼格式和jdk的版本號 -->
   <properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
      <java.version>1.8</java.version>
   </properties>

   <dependencies>

      <!--  -->
      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-web</artifactId>
         <exclusions>
            <exclusion>
               <groupId>org.springframework.boot</groupId>
               <artifactId>spring-boot-starter-tomcat</artifactId>
            </exclusion>
         </exclusions>
      </dependency>

      <!-- servlet -->
      <dependency>
         <groupId>javax.servlet</groupId>
         <artifactId>javax.servlet-api</artifactId>
         <scope>provided</scope>
      </dependency>

   </dependencies>

   <build>
      <finalName>test</finalName>
      <plugins>
         <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <dependencies>   <!-- 修改程式碼後自動生效,Reload Java classes without restarting the container -->
               <dependency>
                  <groupId>org.springframework</groupId>
                  <artifactId>springloaded</artifactId>
               </dependency>
            </dependencies>
         </plugin>
      </plugins>
   </build>

   <!-- 設定主倉庫,按設定順序進行查詢。 -->
   <repositories>
      <!-- <repository> <id>nexus-repos</id> <name>Team Nexus Repository</name>
            <url>http://123.206.197.44:8081/nexus/content/groups/public</url> </repository> -->
      <repository>
         <id>aliyun-repos</id>
         <name>aliyun Repository</name>
         <url>http://maven.aliyun.com/nexus/content/groups/public</url>
      </repository>
      <repository>
         <id>jeecg</id>
         <name>jeecg Repository</name>
         <url>http://maven.jeecg.org/nexus/content/repositories/jeecg</url>
         <snapshots>
            <enabled>false</enabled>
         </snapshots>
      </repository>
      <repository>
         <id>jeecg-snapshots</id>
         <name>jeecg-snapshots Repository</name>
         <url>http://maven.jeecg.org/nexus/content/repositories/snapshots</url>
         <snapshots>
            <enabled>true</enabled>
         </snapshots>
      </repository>
      <repository>
         <id>java-repos</id>
         <name>Java Repository</name>
         <url>http://download.java.net/maven/2/</url>
      </repository>

      <repository>
         <id>springsource-repos</id>
         <name>SpringSource Repository</name>
         <url>http://repo.spring.io/release/</url>
      </repository>

      <repository>
         <id>central-repos</id>
         <name>Central Repository</name>
         <url>http://repo.maven.apache.org/maven2</url>
      </repository>

      <repository>
         <id>central-repos2</id>
         <name>Central Repository 2</name>
         <url>http://repo1.maven.org/maven2/</url>
      </repository>

      <repository>
         <id>activiti-repos</id>
         <name>Activiti Repository</name>
         <url>https://maven.alfresco.com/nexus/content/groups/public</url>
      </repository>

      <repository>
         <id>activiti-repos2</id>
         <name>Activiti Repository 2</name>
         <url>https://app.camunda.com/nexus/content/groups/public</url>
      </repository>

      <repository>
         <id>spring-milestone</id>
         <url>http://repo.spring.io/libs-release</url>
      </repository>
   </repositories>
   <!-- 設定外掛倉庫 -->
   <pluginRepositories>
      <!-- 如有Nexus私服, 取消註釋並指向正確的伺服器地址. -->
      <!-- <pluginRepository> <id>nexus-repos</id> <name>Team Nexus Repository</name>
            <url>http://123.206.197.44:8081/nexus/content/groups/public</url> </pluginRepository> -->
      <pluginRepository>
         <id>aliyun-repos</id>
         <name>aliyun Repository</name>
         <url>http://maven.aliyun.com/nexus/content/groups/public</url>
      </pluginRepository>
   </pluginRepositories>


</project>