spring cloud-学习之路(一):搭建一个简单的Springboot项目
来源:互联网 发布:nginx 不允许加参数 编辑:程序博客网 时间:2024/06/04 21:56
文件目录(注意:Springboot启动类App.class必须放在最外层)
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.crazy_qu.sc</groupId> <artifactId>springboot-helloWorld</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <!-- 启用springboot项目必须引入spring-boot-starter-parent依赖,下面这个依赖中已经集成了 --> <parent> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-parent</artifactId> <version>Brixton.RELEASE</version> <relativePath /> </parent> <dependencies> <!--web应用基本环境配置 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies> <build> <plugins> <!-- 要部署运行spring boot应用,首选要打包spring boot应用,你在pom文件中看到的spring-boot-maven-plugin插件就是打包spring boot应用的。 --> <!-- D:\springboot-helloWorld>mvn package 打包过后就可以进入target目录使用java原生命令执行这个应用了。 D:\springboot-helloWorld\target>java -jar cloud-simple-helloword-0.0.1.jar -(执行的时候是两个横杠)-server.port=8081 如此,你就看到一个基于jar包的web应用启动了。 --> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build></project>
App.class
package com.crazy_qu.hello;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.context.annotation.ComponentScan;/** * Created by crazy on 2017/11/29. */@SpringBootApplication@ComponentScan(basePackages = {"com.crazy_qu.hello.controller"})public class App { public static void main(String[] args){ SpringApplication.run(App.class, args); }}
AppController.class
package com.crazy_qu.hello.controller;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.ResponseBody;/** * Created by crazy on 2017/11/29. */@Controllerpublic class AppController { @RequestMapping("/") @ResponseBody public String getResult(){ return "hello world"; }}
代码写好之后,直接在浏览器中访问:http://localhost:8080/
一个简单的springboot项目就搭建完成了
阅读全文
0 0
- spring cloud-学习之路(一):搭建一个简单的Springboot项目
- 搭建一个基础的Spring Cloud项目
- 快速搭建一个简单的springboot项目
- SpringBoot(一):快速搭建一个springboot项目
- 一起学习springboot[一,简单的springboot工程搭建]
- Spring-Cloud学习之路-简单的Eureka
- Spring Boot 学习(一) 快速搭建SpringBoot 项目
- Spring Boot 学习(一) 快速搭建SpringBoot 项目
- Spring Boot 入门 (一)——建一个最简单的springboot项目
- 【Spring Cloud学习】 搭建简单的服务注册中心Spring cloud Eureka
- 简单的springboot项目搭建
- spring cloud-学习之路(二):搭建一个config repository 和config server
- 简单springboot及springboot cloud环境搭建
- 02搭建一个简单的spring项目
- 一个简单的Springboot项目
- Spring基础之搭建简单的项目
- spring cloud初学者--简单的web项目
- SpringBoot 学习记录(一): 简单web项目
- Glide图片加载框架的学习
- 【总结】Mac下AndroidStudio快捷键
- caffe出现error while loading shared libraries: libopencv_core.so.3.1: cannot open shared object file:
- Android 蓝牙开发,蓝牙连打印机。
- 通过TabLayout自定义tab实现图文混搭导航栏
- spring cloud-学习之路(一):搭建一个简单的Springboot项目
- PPT另存为pdf的图片失真问题解决
- Android事件分发详解-心得
- 虫虫的java之旅(源码篇)---Object
- android ble蓝牙开发
- 1)编写Animal接口,接口中声明run()方法; 2)定义Bird类和Fish类实现Animal接口; 3)编写Bird类和Fish类的测试程序,并调用其中的run()方法
- mysql格式化日期
- 大兴公寓的那场火,烧毁了我的所有
- 函数模板