springBoot入门实例
来源:互联网 发布:网络攻击的种类是什么 编辑:程序博客网 时间:2024/06/18 13:02
环境:idea+java8
1.新建maven工程
2.在pom.xml中导入相应包
<?xml version="1.0" encoding="UTF-8"?><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.zdy.test</groupId> <artifactId>springBoot</artifactId> <version>1.0-SNAPSHOT</version> <name>springBoot</name> <url>http://maven.apache.org</url> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.4.3.RELEASE</version> </parent> <!-- Add typical dependencies for a web application --> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> </dependencies> <!-- Package as an executable jar --> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build></project>3.在src/main/java下新建包com.zdy.springBoot,在此包下新建类Application.java
package com.springBoot;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;/** * Created by zengd on 2017/10/19. */
@SpringBootApplication@RestControllerpublic class Application { @RequestMapping("/") public String greeting() { return "Hello World!"; } public static void main(String[] args) { // TODO Auto-generated method stub SpringApplication.run(Application.class, args); }}
4.启动main方法
启动成功。在浏览器中访问http://localhost:8080/,显示Hello World!
**注意,Application.java一定要放在包下,不可以直接放在src/main/java下,否则启动时会报错阅读全文
0 0
- springboot入门实例
- SpringBoot入门实例
- springBoot入门实例
- dubbo+Springboot入门实例
- 将springBoot项目部署到docker入门实例
- SpringBoot入门
- springboot入门
- springboot 入门
- springboot 入门
- SpringBoot入门
- SpringBoot入门
- SpringBoot入门
- Springboot入门
- springboot入门
- SpringBoot入门
- SpringBOOT入门
- SpringBoot 入门
- springboot入门
- 第五周【项目1
- MySQL体系结构
- 笨方法学习Python-习题7:更多打印
- Junit测试
- 在自己的服务器上部署 GitLab 社区版
- springBoot入门实例
- 第七周——建立顺序环形队列算法库
- 分布式数据库数据一致性原理说明与实现
- lua元表元方法
- 洛谷 1378 油滴扩展
- 操作系统学习
- AndroidStudio打开的类显示多行
- 合并dll到exe中
- 第16篇