Eclipse使用maven搭建简单spring boot application Hello World
来源:互联网 发布:控制软件 编辑:程序博客网 时间:2024/06/04 18:43
说明:本例使用spring-boot 2.0.0.BUILD-SNAPSHOT,需要jdk 1.8+版本,maven需要3.2+版本
1、new project,选择Maven Project
2、选择maven-archetype-webapp
3、在pom.xml中添加spring-boot依赖
4、pom.xml文件如下
<?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.zqy</groupId><artifactId>myproject</artifactId><version>0.0.1-SNAPSHOT</version><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.0.0.BUILD-SNAPSHOT</version></parent><!-- Additional lines to be added here... --><!-- (you don't need this if you are using a .RELEASE version) --><repositories><repository><id>spring-snapshots</id><url>http://repo.spring.io/snapshot</url><snapshots><enabled>true</enabled></snapshots></repository><repository><id>spring-milestones</id><url>http://repo.spring.io/milestone</url></repository></repositories><pluginRepositories><pluginRepository><id>spring-snapshots</id><url>http://repo.spring.io/snapshot</url></pluginRepository><pluginRepository><id>spring-milestones</id><url>http://repo.spring.io/milestone</url></pluginRepository></pluginRepositories><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build></project>
5、新建Example类
6、Example类代码如下:
package myproject;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.EnableAutoConfiguration;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;@RestController@EnableAutoConfigurationpublic class Example {@RequestMapping("/")String home() {return "Hello World!";}public static void main(String[] args) throws Exception {SpringApplication.run(Example.class, args);}}7、运行main方法,启动project
8、启动成功,浏览器中访问:localhost:8080
阅读全文
0 0
- Eclipse使用maven搭建简单spring boot application Hello World
- spring boot(1)-简单搭建 Hello World
- Spring Boot:简单Hello World
- Spring-boot搭建一个简单的Hello World工程
- Spring boot使用 hello world
- Spring Boot系列01-Spring Boot + maven 实现Hello World
- Spring 3 MVC Framework Based Hello World Web Application Example Using Maven, Eclipse IDE And Tomcat
- spring-boot-hello-world
- spring-boot Hello World
- hello World Spring Boot
- 使用Maven构建Spring Boot 第一课之Hello world 程序
- Spring 3 mvc hello world application with maven and jstl
- Spring Boot+Intelli IDEA+Maven创建Hello World
- Eclipse使用Maven搭建Spring Boot应用并访问数据库
- 1.1 使用IntelliJ IDEA搭建Spring-Boot的"Hello World"项目
- spring boot 利用分层结构输出简单的Hello world
- Spring Boot (一) 最简单跑起Hello World!
- spring boot 之 hello world !
- 基于主主复制的mysql读写分离配置
- VPU?APU?GPU?折腾从AMD-GPU回到Intel核显
- java基础(6)- 面向对象(3)
- 函数申明与函数表达式
- 删除链表中重复的结点(链表)
- Eclipse使用maven搭建简单spring boot application Hello World
- java分布式系统部署学习(六)ansible Ad-hoc与commands模块
- 前端 ifram 父页面显示子页面内容
- Springboot 之 解决IDEA读取properties配置文件的中文乱码问题
- Ant的安装与配置
- LintCode: 109. 数字三角形 Java
- iOS 动画实战之Lottie动画
- log4j-over-slf4j与slf4j-log4j12共存stack overflow异常分析
- calico 跨主机容器网络通信