springboot - 应用实践第一个springboot应用
Posted zeromz
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了springboot - 应用实践第一个springboot应用相关的知识,希望对你有一定的参考价值。
1、使用maven创建一个快速启动项目
2、引入相关依赖
<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>com.lfy.cn</groupId> <artifactId>springbootTest-1.0.0</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>springbootTest-1.0.0</name> <url>http://maven.apache.org</url> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.0.RELEASE</version> </parent> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> </dependency> </dependencies> </project>
3、HelloController.java
package com.lfy.cn.springbootTest; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class HelloController @RequestMapping("/HelloController/hello") public String hello() return "hello spring boot";
4、App.java
package com.lfy.cn.springbootTest; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; /** * Hello world! * */ @SpringBootApplication public class App public static void main( String[] args ) SpringApplication.run(App.class,args);
5、在App.java中右键,作为Java Application启动运行
以上是关于springboot - 应用实践第一个springboot应用的主要内容,如果未能解决你的问题,请参考以下文章