Maven搭建springboot项目的方法步骤

网友投稿 271 2022-12-08


Maven搭建springboot项目的方法步骤

Maven搭建springboot项目

本文是基于Windows 10系统环境,使用Maven搭建springboot项目

Windows 10

apache-maven-3.6.0

IntelliJ IDEA 2018.3.4 x64

一、springboot项目搭建

(1) 新建目录

在某个可用目录下,新建一个文件夹,本文新建目录为 D:\demo\zs200

(2) 创建maven父工程zs200a-parent

填写项目maven坐标

填写项目名称和路径

(2) maven父工程zs200a-parent的pom文件

xmlns:xsi="http://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">

4.0.0

com.chaoyue.zs200a

zs200a-parent

1.0-SNAPSHOT

pom

org.springframework.boot

spring-boot-starter-parent

2.0.6.RELEASE

UTF-8

UTF-8

1.8

Finchley.SR2

org.springframework.cloud

spring-cloud-dependencies

${spring-cloud.version}

pom

import

xmlns:xsi="http://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">

4.0.0

com.chaoyue.zs200a

zs200a-parent

1.0-SNAPSHOT

pom

org.springframework.boot

spring-boot-starter-parent

2.0.6.RELEASE

UTF-8

UTF-8

1.8

Finchley.SR2

org.springframework.cloud

spring-cloud-dependencies

${spring-cloud.version}

pom

import

(3) 创建maven子工程zs200a-user

(4) maven子工程zs200a-user的pom文件

xmlns:xsi="http://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">

zs200a-parent

com.chaoyue.zs200a

1.0-SNAPSHOT

4.0.0

com.chaoyue.zs200a

zs200a-user

1.0-SNAPSHOT

pom

xmlns:xsi="http://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">

zs200a-parent

com.chaoyue.zs200a

1.0-SNAPSHOT

4.0.0

com.chaoyue.zs200a

zs200a-user

1.0-SNAPSHOT

pom

(5) 创建maven子工程zs200a-user-interface

(6) maven子工程zs200a-user-interface的pom文件

xmlns:xsi="http://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">

zs200a-user

com.chaoyue.zs200a

1.0-SNAPSHOT

4.0.0

com.chaoyue.zs200a

zs200a-user-interface

1.0-SNAPSHOT

org.projectlombok

lombok

xmlns:xsi="http://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">

zs200a-user

com.chaoyue.zs200a

1.0-SNAPSHOT

4.0.0

com.chaoyue.zs200a

zs200a-user-interface

1.0-SNAPSHOT

org.projectlombok

lombok

(7) zs200a-user-interface工程中新建一个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) 创建maven子工程zs200a-user-service

(9) maven子工程zs200a-user-service的pom文件

xmlns:xsi="http://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">

zs200a-user

com.chaoyue.zs200a

1.0-SNAPSHOT

4.0.0

com.chaoyue.zs200a

zs200a-user-service

1.0-SNAPSHOT

org.springframework.cloud

spring-cloud-starter-netflix-eureka-client

org.springframework.boot

spring-boot-starter-web

com.chaoyue.zs200a

zs200a-user-interface

1.0-SNAPSHOT

org.springframework.boot

spring-boot-maven-plugin

xmlns:xsi="http://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">

zs200a-user

com.chaoyue.zs200a

1.0-SNAPSHOT

4.0.0

com.chaoyue.zs200a

zs200a-user-service

1.0-SNAPSHOT

org.springframework.cloud

spring-cloud-starter-netflix-eureka-client

org.springframework.boot

spring-boot-starter-web

com.chaoyue.zs200a

zs200a-user-interface

1.0-SNAPSHOT

org.springframework.boot

spring-boot-maven-plugin

(10) zs200a-user-service工程中新建一个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工程整体打包并部署到本地仓库


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:详解在Spring MVC或Spring Boot中使用Filter打印请求参数问题
下一篇:JAVA随机数随机字母的实现(微信抢红包小练习)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~