線上快速建立SpringBoot專案

Louis碼農工具人發表於2020-08-13

都2020年了,你還在手動建立SpringBoot專案嗎?今天教你線上快速建立一個SpringBoot專案,瞬間高大上有木有!

進入正題,首先開啟建立SpringBoot的官網:https://start.spring.io/

 

 

 

①選擇Project構建工具 -> Maven Project

②選擇Language -> Java

③選擇SpringBoot版本 -> 2.3.2當前穩定版本

④填入

  Group:一般是倒域名【org.louis】

  Artifact:專案名【blog】

  Name:專案名【blog】

  Description:描述【A popular online mall.】

  Packaging:打包型別【Jar】,SpringBoot執行時的打包專案,一般SpringBoot都是打為Jar包,如果使用Tomcat容器的話就選擇War包

  Java:Java版本,主流專案選Java8,個人專案可以選擇Java11進行測試

 

接下來是重點:引入依賴【Dependencies

這裡推薦一些經常使用的依賴:

①Spring Web:Build web, including RESTful, applications using Spring MVC. Uses Apache Tomcat as the default embedded container.

②Spring Data JPA:Persist data in SQL stores with Java Persistence API using Spring Data and Hibernate.

③Spring Data Redis:Advanced and thread-safe Java Redis client for synchronous, asynchronous, and reactive usage. Supports Cluster, Sentinel, Pipelining, Auto-Reconnect, Codecs and much more.

④Spring Boot Actuator:Supports built in (or custom) endpoints that let you monitor and manage your application - such as application health, metrics, sessions, etc.

⑤MySQL Driver:MySQL JDBC and R2DBC driver.

⑥Java Mail Sender:Send email using Java Mail and Spring Framework's JavaMailSender.

Thymeleaf:A modern server-side Java template engine for both web and standalone environments. Allows HTML to be correctly displayed in browsers and as static prototypes.

Lombok:Java annotation library which helps to reduce boilerplate code.

 

再額外推薦一些常用的依賴:

        <!-- WebSocket -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-websocket</artifactId>
        </dependency>

        <!-- Test -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- gson依賴 -->
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.8.2</version>
        </dependency>

        <!--依賴nekoHTML 1.9.15 or newer的版本  -->
        <dependency>
            <groupId>net.sourceforge.nekohtml</groupId>
            <artifactId>nekohtml</artifactId>
            <version>1.9.22</version>
        </dependency>
        
        <!-- 支援 @ConfigurationProperties 註解 -->  
        <dependency>  
            <groupId>org.springframework.boot</groupId>  
            <artifactId>spring-boot-configuration-processor</artifactId>  
            <optional>true</optional>  
        </dependency>  
        
        <!-- JWT  Token -->
        <dependency>  
            <groupId>io.jsonwebtoken</groupId>  
            <artifactId>jjwt</artifactId>  
            <version>0.6.0</version>  
        </dependency>

        <!-- 檔案上傳所依賴的jar包 -->
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.3.1</version>
        </dependency>
        
        <dependency>
            <groupId>commons-net</groupId>
            <artifactId>commons-net</artifactId>
            <version>3.3</version>
        </dependency>

        <dependency>
            <groupId>cn.hutool</groupId>
            <artifactId>hutool-all</artifactId>
            <version>4.5.10</version>
        </dependency>
        
        <!-- https://mvnrepository.com/artifact/com.google.zxing/core -->
        <dependency>
            <groupId>com.google.zxing</groupId>
            <artifactId>core</artifactId>
            <version>3.1.0</version>
        </dependency>
        
        <!-- Swagger2-ui用於生成、描述、呼叫和視覺化 RESTful 風格的 Web 服務 -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.9.2</version>
        </dependency> 
        
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.9.2</version>
        </dependency>
        
        <!-- alibabaJSON -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.58</version>
        </dependency>
        
        <!-- 實現跨伺服器檔案傳輸 -->
        <dependency>
          <groupId>com.jcraft</groupId>
          <artifactId>jsch</artifactId>
          <version>0.1.49</version>
        </dependency>

        <!-- Emoji表情 -->
        <dependency>
            <groupId>com.vdurmont</groupId>
            <artifactId>emoji-java</artifactId>
            <version>4.0.0</version>
        </dependency>

        <!--WebSocket作為Java客戶端-->
        <dependency>
            <groupId>org.java-websocket</groupId>
            <artifactId>Java-WebSocket</artifactId>
            <version>1.3.5</version>
        </dependency>

        <!--compress壓縮解壓包-->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-compress</artifactId>
            <version>1.18</version>
        </dependency>

        <!-- ZeroMQ -->
        <dependency>
              <groupId>org.zeromq</groupId>
              <artifactId>jeromq</artifactId>
              <version>0.3.1</version>
        </dependency>

        <!-- @Transactional註解寫在class上,就會導致InterceptorBinding類報錯 -->
        <!-- 引入InterceptorBinding依賴, 啟動不會報錯,否則直接註解方法不會報錯-->
        <dependency>
            <groupId>javax.interceptor</groupId>
            <artifactId>javax.interceptor-api</artifactId>
            <version>1.2</version>
        </dependency>

 

 

 

 

配置好之後,點選 EXPLORE 開始匯出

 

 

 

在彈窗後點選 DOWNLOAD 開始下載

 

現在,一個完整的SpringBoot專案就建立好了!

 

 

解壓出來用編輯器開啟就可以開心的擼程式碼了!

 

推薦閱讀:強烈推薦的 IntelliJ IDEA 外掛,別說我沒告訴你

 

喜歡的話記得推薦收藏哦~~~

 

相關文章