eclipse maven项目 class类部署不到tomcat下_Springboot介绍以及用Eclipse搭建一个简单的Springboot项目教程

简述

本文主要介绍Springboot以及用Eclipse搭建一个简单的Springboot项目。

Springboot简介

Springboot是由Pivotal团队提供的全新框架,其设计目的是用来简化Spring应用初始搭建以及开发过程。该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配置。Spring Boot其实就是一个整合很多可插拔的组件(框架),内嵌了使用工具(比如内嵌了Tomcat、Jetty等),方便开发人员快速搭建和开发的一个框架。

简单来说就是:简化开发、整合框架、减少配置、快速搭建。

SpringBoot特点

快速搭建:搭建项目快,几秒钟就可以搭建完成;

方便测试:内置了JUnit、Spring Boot Test等多种测试框架;

内嵌容器:内嵌了Tomcat、Jetty等,省去了配置Tomcat的繁琐;

方便监控:Spring Boot Actuator组件提供了应用的系统监控,可以查看应用配置详细信息;

减少配置:基于注解的零配置思想;

整合框架:各种流行框架,springmvc,mybatis,spring cloud无缝整合;

环境配置

Eclipse IDE Version: 2019-03 (4.11.0)

Java version: 1.8.0_151

创建项目

ed2972038704806bf31d3002d36beb0e.png

图 1 新建Maven项目

1db16bd49eb717b029352040ec79a357.png

图 2 选择项目的模板

fa59bfc31d446fe9ef6ef0c737e0704c.png

图 3 指定原型参数

b9130fe4ea4a95b51f549fb303b3b30f.png

图 4 项目初始化目录

修改Maven仓库

Window->Preferences->Maven->User Settings,找到你本地设置的setting文件。

a0e00bcb860014495daae6a56c599bf6.png

图 5 修改Maven仓库

settings-springboot.xm文件

<?xml version="1.0" encoding="UTF-8"?>F://.m2/repo_springmaven-releasesadminadmin123maven-snapshotsadminadmin123maven-centraladminadmin123alimavencentralaliyun mavenhttp://maven.aliyun.com/nexus/content/repositories/central/nexusmaven-releaseshttp://maven-releasestruetruemaven-snapshotshttp://maven-snapshotstruetruemaven-releaseshttp://maven-releasestruetruemaven-snapshotshttp://maven-snapshotstruetruenexus

修改pom.xml文件

添加项目依赖和编译插件

pom.xml文件

4.0.0com.springspringbootDemo0.0.1-SNAPSHOTjarspringbootDemohttp://maven.apache.orgorg.springframework.bootspring-boot-starter-parent2.0.2.RELEASEUTF-8junitjunittestorg.springframework.bootspring-boot-starter-weborg.springframework.bootspring-boot-maven-plugin

文件配置

application.properties文件

#服务端口server.port=80

Application.java文件

package com.spring.springboot;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;/**** 

Title: Application

**

Description: 应用启动类

** @author** @date 2020年5月18日**/@SpringBootApplicationpublic class Application{public static void main( String[] args ){SpringApplication.run(Application.class, args);}}

UserController.java文件

package com.spring.springboot.controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.ResponseBody;import org.springframework.web.bind.annotation.RestController;/**** 

Title: UserController

**

Description: 用户管理类

** @author** @date 2020年5月18日**/@RestController@RequestMapping("/user")public class UserController {/****

Title: login

**

Description: 登录方法

** @return**/@RequestMapping("/login")@ResponseBodypublic String login() {return "This is my first springboot demo!";}}

启动应用

52752479301f70eec77058af534eb7b4.png

图 6 启动springboot应用

f8130f9ba327094f8e9a27f34d0bd750.png

图 7 应用启动成功

访问应用

8b0b9a41728c436150640e8331104cde.png

图 8 访问应用

项目目录

a55c1386cfcbaf7ee1e20ff2a85ee284.png

图 9项目目录结构

ok,以上就是Springboot介绍以及用Eclipse搭建一个简单的Springboot项目教程,看完记得转发、点赞和收藏。如果有错误,欢迎批评指正,感谢。

(云渺书斋)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值