这几天开始学习springBoot记录一下(Hello World)

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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.bianqi.spring.first</groupId>
<artifactId>SpringBootFirst</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.1.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>${start-class}</mainClass>
<layout>ZIP</layout>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

2.编写controller

 package org.bianqi.first.demo;

 import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; @RestController
@EnableAutoConfiguration
@ComponentScan
public class FirstDemo { @Autowired
private FirstService fs; @RequestMapping("/")
String home(){
fs.demo();
return "hello world!";
}
public static void main(String[] args) {
SpringApplication.run(FirstDemo.class, args);
} }

3.编写service的接口

 package org.bianqi.first.demo;

 public interface FirstService {
public String demo();
}

4.编写service层实现类

 package org.bianqi.first.demo;

 import org.springframework.stereotype.Service;

 @Service
public class FirstServiceImpl implements FirstService{ public String demo(){
System.out.println("hhhhh");
return "helloworld我爱你";
}
}

在Controller中通过main方法启动~浏览器访问http://localhost:8080/ 显示helloworld 并且控制台打印hhhhh

SpringBoot学习helloworld的更多相关文章

  1. springboot学习(一)——helloworld

    以下内容,如有问题,烦请指出,谢谢 springboot出来也很久了,以前零散地学习了不少,不过很长时间了都没有在实际中使用过了,忘了不少,因此要最近准备抽时间系统的学习积累下springboot,给 ...

  2. springboot 学习资源推荐

    springboot 是什么?对于构建生产就绪的Spring应用程序有一个看法. Spring Boot优先于配置的惯例,旨在让您尽快启动和运行.(这是springboot的官方介绍) 我们为什么要学 ...

  3. springboot学习(二)——springmvc配置使用

    以下内容,如有问题,烦请指出,谢谢 上一篇讲解了springboot的helloworld部分,这一篇开始讲解如何使用springboot进行实际的应用开发,基本上寻着spring应用的路子来讲,从s ...

  4. Springboot学习记录1--概念介绍以及环境搭建

    摘要:springboot学习记录,环境搭建: 官方文档地址:https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/ht ...

  5. SpringBoot学习笔记

    SpringBoot个人感觉比SpringMVC还要好用的一个框架,很多注解配置可以非常灵活的在代码中运用起来: springBoot学习笔记: .一.aop: 新建一个类HttpAspect,类上添 ...

  6. SpringBoot学习(3)-SpringBoot添加支持CORS跨域访问

    SpringBoot学习(3)-SpringBoot添加支持CORS跨域访问 https://blog.csdn.net/yft_android/article/details/80307672

  7. Springboot学习07-数据源Druid

    Springboot学习07-数据源Druid 关键字 Druid 前言 学习笔记 正文 1-Druid是什么 Druid是阿里巴巴开源平台上的一个项目,整个项目由数据库连接池.插件框架和SQL解析器 ...

  8. Springboot学习06-Spring AOP封装接口自定义校验

    Springboot学习06-Spring AOP封装接口自定义校验 关键字 BindingResult.Spring AOP.自定义注解.自定义异常处理.ConstraintValidator 前言 ...

  9. Springboot学习05-自定义错误页面完整分析

    Springboot学习06-自定义错误页面完整分析 前言 接着上一篇博客,继续分析Springboot错误页面问题 正文 1-自定义浏览器错误页面(只要将自己的错误页面放在指定的路径下即可) 1-1 ...

随机推荐

  1. ST-LINK调试完成

    今天真是一波三折啊. 买回来的st-link刚开始不会用,各种百度,还好有两个很好的教程.连接发在下面吧. http://blog.csdn.net/TXF1984/article/details/4 ...

  2. 【从无到有】JavaScript新手教程——1.简介、变量和运算符

    今天带大家来学习一下在网页制作过程中很常用的JavaScript(简称JS).   一.JS的作用: 表单验证,减轻服务端的压力 添加页面动画效果 动态更改页面内容 Ajax网络请求 二.[使用JS的 ...

  3. SpringMVC4+MyBatis+SQL Server2014 基于SqlSession实现读写分离(也可以实现主从分离)

    前言 上篇文章我觉的使用拦截器虽然方便快捷,但是在使用读串还是写串上你无法控制,我更希望我们像jdbc那样可以手动控制我使用读写串,那么这篇则在sqlsession的基础上实现读写分离, 这种方式则需 ...

  4. AIX误删除LV后如何进行现场保护和数据恢复工作

    在AIX环境下,若因维护误操作.存储mapping错误等,不小心将LV误删除,这种损失通常是巨大的.删除后的不当保护及恢复操作可能使数据无法恢复,也可能增加处理的时间与算法复杂度.如何有效保护现场,并 ...

  5. Unix系统操作指令汇总

    一.目录及文件操作命令 1.1 ls 语法: ls [-RadCxmlnogrtucpFbqisf1] [目录或文件--] 说明: ls 命令列出指定目录下的文件,缺省目录为当前目录 ./,缺省输出顺 ...

  6. 设计模式之“Observer”注疏#01

    原文首发于我的微信公众号:GeekArtT. Observer设计模式是为了解决"信息同步更新"的问题而存在的.它试图解决这样一个问题:如果有"一堆对象"都跟随 ...

  7. hdu4417 Super Mario

    Problem Description Mario is world-famous plumber. His “burly” figure and amazing jumping ability re ...

  8. endsWith is not a function解决方案

    在写javascript脚本时,用某些方法,有时候会碰到"XXX is not a function"之类的报错. 出现这种情况,主要是因为某些方法在低版本浏览器上不支持.比如说& ...

  9. 重启mysql提示:The server quit without updating PID file问题的解决办法

    今天因为需要开启事件调度器event_scheduler,所以修改了mysql的配置文件/etc/my.cnf 就因为配置多了个分号,导致一直启动失败,如下图所示: 然后去网上搜了帖子(MySQL提示 ...

  10. Play学习 - 体验网页模板

    在经过无数个尝试后,最终用sbt把play所依赖的所有包都下载下来了,现在可以非常快速编译运行了.今天体验了下网页模板,觉得非常不错,在这里做个简单的介绍. 原文说明: A Play Scala te ...