spring boot第一个helloworld

       最近很多公司都比较流行spring boot所以就先研究下第一个helloWord的编写

首先因为spring boot是maven项目,我们先在eclipse上搭建一个maven工程然后再部署

只需要配置pom.xml

第一步:新建maven工程:

第二步:导入jar包(pom.xml)

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>words</groupId>
  <artifactId>springboot</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>springboot Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <!-- spring boot web -->
     <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
  </dependencies>
  <build>
    <finalName>springboot</finalName>
  </build>
  <!-- spring boot -->
  <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.3.4.RELEASE</version>
    </parent>
</project>

然后在此目录下新建包和主函数类写我们的第一个hello world

第三步:编写启动函数

package com.springboot.test;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@EnableAutoConfiguration
public class boottest {

	@RequestMapping("/hello")
	@ResponseBody
	String SAYHI() {
		return "hello world spring-boot";
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		SpringApplication.run(boottest.class, args);
	}

}

然后可以就像管网的那样直接运行主函数就可以了

第四步:就是打开浏览器localhost:8080/hello直接访问

 

下一篇文章我们再来介绍下怎么使用spring boot+shiro整合

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值