Maven搭建springboot項(xiàng)目的方法步驟
Maven搭建springboot項(xiàng)目
本文是基于Windows 10系統(tǒng)環(huán)境,使用Maven搭建springboot項(xiàng)目
- Windows 10
- apache-maven-3.6.0
- IntelliJ IDEA 2018.3.4 x64
一、springboot項(xiàng)目搭建
(1) 新建目錄
在某個(gè)可用目錄下,新建一個(gè)文件夾,本文新建目錄為 D:\demo\zs200
(2) 創(chuàng)建maven父工程zs200a-parent


填寫項(xiàng)目maven坐標(biāo)

填寫項(xiàng)目名稱和路徑

(2) maven父工程zs200a-parent的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.chaoyue.zs200a</groupId>
<artifactId>zs200a-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.6.RELEASE</version>
<relativePath/>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Finchley.SR2</spring-cloud.version>
</properties>
<dependencyManagement>
<dependencies>
<!-- springCloud -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
(3) 創(chuàng)建maven子工程zs200a-user



(4) maven子工程zs200a-user的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">
<parent>
<artifactId>zs200a-parent</artifactId>
<groupId>com.chaoyue.zs200a</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.chaoyue.zs200a</groupId>
<artifactId>zs200a-user</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
</project>
(5) 創(chuàng)建maven子工程zs200a-user-interface




(6) maven子工程zs200a-user-interface的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">
<parent>
<artifactId>zs200a-user</artifactId>
<groupId>com.chaoyue.zs200a</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.chaoyue.zs200a</groupId>
<artifactId>zs200a-user-interface</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>
</project>
(7) zs200a-user-interface工程中新建一個(gè)User類

package com.chaoyue.zs200a.user.pojo;
import lombok.Data;
import java.util.Date;
@Data
public class User {
private Long id;
private String username;
private String password;
private String phone;
private Date created;
private String salt;
}
(8) 創(chuàng)建maven子工程zs200a-user-service


(9) maven子工程zs200a-user-service的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">
<parent>
<artifactId>zs200a-user</artifactId>
<groupId>com.chaoyue.zs200a</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.chaoyue.zs200a</groupId>
<artifactId>zs200a-user-service</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.chaoyue.zs200a</groupId>
<artifactId>zs200a-user-interface</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
(10) zs200a-user-service工程中新建一個(gè)UserServiceApplication類

package com.chaoyue.zs200a.user;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@SpringBootApplication
@EnableDiscoveryClient
public class UserServiceApplication {
public static void main(String[] args) {
SpringApplication.run(UserServiceApplication.class, args);
}
}
(11) maven工程整體打包并部署到本地倉庫

到此這篇關(guān)于Maven搭建springboot項(xiàng)目的方法步驟的文章就介紹到這了,更多相關(guān)Maven搭建springboot內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
關(guān)于Mybatis中foreach遍歷Map的實(shí)現(xiàn)示例
這篇文章主要介紹了關(guān)于Mybatis中foreach遍歷Map的實(shí)現(xiàn)示例,MyBatis?是一款優(yōu)秀的半自動(dòng)的ORM持久層框架,它支持自定義?SQL、存儲(chǔ)過程以及高級(jí)映射,需要的朋友可以參考下2023-05-05
什么情況下會(huì)出現(xiàn)java.io.IOException?:?Broken?pipe這個(gè)錯(cuò)誤以及解決辦法
這篇文章主要介紹了什么情況下會(huì)出現(xiàn)java.io.IOException?:?Broken?pipe這個(gè)錯(cuò)誤以及解決辦法的相關(guān)資料,這個(gè)錯(cuò)誤表示通信另一端已關(guān)閉連接,常發(fā)生在客戶端關(guān)閉連接、網(wǎng)絡(luò)超時(shí)或資源不足等情況,文中將解決辦法介紹的非常詳細(xì),需要的朋友可以參考下2024-10-10
深入了解Java8中的時(shí)區(qū)日期時(shí)間
Java?在?java.time?包中也提供了幾個(gè)類用于處理需要關(guān)注時(shí)區(qū)的日期時(shí)間?API,本文將通過簡單的示例講講它們的用法,需要的可以參考一下2023-04-04
Java 數(shù)據(jù)結(jié)構(gòu)七大排序使用分析
這篇文章主要介紹了Java常用的排序算法及代碼實(shí)現(xiàn),在Java開發(fā)中,對(duì)排序的應(yīng)用需要熟練的掌握,這樣才能夠確保Java學(xué)習(xí)時(shí)候能夠有扎實(shí)的基礎(chǔ)能力。那Java有哪些排序算法呢?本文小編就來詳細(xì)說說Java常見的排序算法,需要的朋友可以參考一下2022-04-04
Windows下將JAVA?jar注冊(cè)成windows服務(wù)的方法
這篇文章主要介紹了Windows下將JAVA?jar注冊(cè)成windows服務(wù)的方法,本文通過圖文并茂的形式給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-07-07
在webservice里調(diào)用耗時(shí)方法出錯(cuò)的解決方案
這篇文章主要介紹了在webservice里調(diào)用耗時(shí)方法出錯(cuò)的解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2021-07-07

