Spring boot输出hellowrold

一.

目录

一.hellowrold Spring boot

二.一些参考链接


hellowrold Spring boot

准备工作:

  • jdk 1.8
  • maven3.0+
  • Idea

  • 创建项目     File -->new  -->project;

  • 选择spring Initializr  点击next

  •  确定项目名称  Java version选择8,点击next

 

  • Web下勾选Spring Web Start,(网上创建springboot项目多是勾选Web选项,而较高版本的 Springboot没有此选项,勾选Spring Web Start即可,2.1.8版本是Spring Web);Template Englines勾选Thymeleaf;SQL勾选:MySQL Driver,JDBC API 和 MyBatis Framework三项;点击next;

  •  刚创建好的项目结构

  •  开始项目  再java->com.example.demo2下新增一个controller包,再在包下新建一个Controller类

 

  •  Controller里面内容
package com.example.demo2.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class Controller {

    @RequestMapping("/hello")
        public String hellowrold(){
        return "hellowrold Spring boot!";
    }
}
  •  application.properties内容
#访问根路径

#应用名称
spring.application.name=springboot-demo

#访问端口号
server.port=8080

#编码格式
server.tomcat.uri-encoding=utf-8

#数据库相关配置
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/sql_test
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.max-idle=10
spring.datasource.max-wait=10000
spring.datasource.min-idle=5
spring.datasource.initial-size=5

#session生命周期
server.servlet.session.timeout=30m
 
 

  • 运行Demo2Application

  •  出现以下内容就成功了
  •  打开浏览器,在导航栏输入 http://localhost:8080/hello就可显示输出结果。

 输出成功!

二.一些参考链接

IDEA创建SpringBoot项目输出hello world——新手教程(1)

报错:Failed to configure a DataSource: 'url' attribute is not specified and no embedd

  • 2
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值