springboot--helloworld

2025-05-17 10:32:38

本文完成一个简单的 Web 应用,输出“ Hello World”。例子基于己经安装好的环境只需要 IDK8 、 Ec l ipse,还有 Maven

工具/原料

eclipse

maven

jdk1.8

1、创建maven工程

1、在eclipse的package explore中右键-->new -->other --> maven --> 罪焐芡拂maven project, 弹出一个面板,选中create a simple project后单机next,

springboot--helloworld

2、填写group id 和 artifact id,packaging选择jar后点击finish,完成创建

springboot--helloworld
springboot--helloworld

2、配置pom

1、打开pom.xml文件

springboot--helloworld

2、添加如下图中内容,使之成为一个spring boot 应用因为搭建的是web应用,所以需要添加spring-boot-starter-web依赖

springboot--helloworld

3、最后,因为springboot2.0可能在中央仓库中不存在,需要添加如下

springboot--helloworld

3、实现helloworld

1、如图中所示,创建两个文件,分别是Ch1Application.java和HelloWorldController.java文件

springboot--helloworld

2、Ch1Application.java和HelloWorldController.java文件代码如下

springboot--helloworld
springboot--helloworld

3、runCh1Application.java文件

springboot--helloworld

4、浏览器中输入url: http://127.0.0.1:8080/say.html,成功

springboot--helloworld
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢