使用Maven项目搭建SpringBoot框架的简单web项目。

目录

前言:

搭建步骤:

1、新建Maven项目骨架。

2、pom.xml文件中,继承SpringBoot的Maven模版

3、pom.xml文件中,添加web项目所需的依赖

4、pom.xml文件中,添加SpringBoot项目打包需要的插件依赖

5、执行maven update project.

6、添加index.html主页。

7、添加SpringBoot启动入口类

8、访问http://127.0.0.1   

9、源码:


前言:

     对于能够自己搭建框架,并且也有自己的快速开发框架的程序员来说,SpringBoot并没有多大的魅力,而且这么方便的东西用起来着实无聊。

    但是大家都在用,来凑个热闹。

 

 

搭建步骤:

1、新建Maven项目骨架。

2、pom.xml文件中,继承SpringBoot的Maven模版

也就是SpringBoot的基本依赖(也就是人家帮你配置好了)

    <!-- 继承Spring boot 相关依赖(免去自己配置) -->
    <parent>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-parent</artifactId>
	<version>2.0.2.RELEASE</version>
    </parent>

3、pom.xml文件中,添加web项目所需的依赖

去除junit的版本(因为SpringBoot的parent里已经定义了版本,他们已经处理了各种依赖的版本冲突问题)

        <dependencies>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<scope>test</scope>
		</dependency>
		<!-- 如果是web应用,需要引入的web相关依赖 -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
	</dependencies>

4、pom.xml文件中,添加SpringBoot项目打包需要的插件依赖

        <build>
		<plugins>
			<!-- Spring boot 打包插件 -->
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>

5、执行maven update project.

6、添加index.html主页。

7、添加SpringBoot启动入口类

只要添加这2个红框,用什么类都可以。直接当作普通的main函数执行就行。

 

8、访问http://127.0.0.1   

(默认端口8080,可以进行配置)

9、源码:

https://github.com/bof-jangle/springboot.demo

https://download.csdn.net/download/Bof_jangle/12432150

  • 6
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值