《spring-boot学习》-02-hello world
2017-02-24 15:47
274 查看
1.新建一个maven项目
pox.xml文件内容如下
这个地方写错可能在运行的时候报错
2.编写controller文件
3.直接运行main方法。可以看到控制台打印出
4.在页面输入http://localhost:8080/hellow 注意这里没有项目名称
pox.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>springBootTest2</groupId> <artifactId>springBootTest2</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>springBootTest2 Maven Webapp</name> <url>http://maven.apache.org</url> <!-- spring boot基本环境 --> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.3.1.RELEASE</version> </parent> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> </dependency> <!--web应用基本环境配置 --> <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> --> <finalName>ceshi</finalName> </build> </project>
这个地方写错可能在运行的时候报错
2.编写controller文件
package com.sishuok.controller; 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; /** * Created by 三劫散仙 on 2015/4/24. */ @Controller @EnableAutoConfiguration public class HellowController { @RequestMapping("/hellow") @ResponseBody public String hellow(){ return "哈喽,Spring Boot !"; } public static void main(String[] args) { //第一个简单的应用, SpringApplication.run(HellowController.class,args); } }
3.直接运行main方法。可以看到控制台打印出
4.在页面输入http://localhost:8080/hellow 注意这里没有项目名称
相关文章推荐
- spring 02 spring注入值
- IntelliJ IDEA 创建spring boot 的Hello World 项目(图解)
- spring学习笔记整理--02(搭建与测试Spring的开发环境)
- Spring Boot实例Hello World Demo
- spring boot 入门(一):IntelliJ IDEA 实现hello world
- spring-02 spring的bean管理(使用注解方式创建对象 附代码)
- Maven+SSM框架(Spring+SpringMVC+MyBatis) - Hello World
- 第四章 Spring Hello World示例 (Spring Framework3.1教程)
- Spring(02)——bean实例化
- Springboot的第一个Hello World程序
- SSH与SSM学习之Spring02——bean元素配置
- 《spring-boot学习》-04-综合开发
- 快速构建可运行的Spring-boot项目(Hello World)
- 关于Spring_02
- IntelliJ IDEA 开发Spring-Boot之Hello World
- Spring 02 核心API
- Spring学习笔记 Hello World
- [spring学习笔记-02]配置bean
- 【有配图】Spring Boot 第一个Hello World 程序
- (1)spring boot起步之Hello World【从零开始学Spring Boot】