springboot项目搭建(一)
来源:互联网 发布:禁止安装软件的软件 编辑:程序博客网 时间:2024/05/23 19:21
一、创建maven聚合工程
这个比较简单,就不在此赘述了。
给出结构图:
二、配置pom文件
1.配置setting文件(这个不是本文重点,也就先不多说了)
2.配置pom文件
a.pom文件一般主要需要配置一下几个部分:
b.因为现在只是简单的搭建一个Hello Word类似的web项目,所以,以上内容就需要简单配置一下即可。
首先,需要配置父项目的信息和当前项目的属性信息。
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.3.RELEASE</version>
</parent>
<!-- 项目属性 -->
<groupId>com.demo</groupId>
<artifactId>QQ</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>QQ</name>
<description>DUBBO-TEST</description>
然后配置springboot项目所依赖的核心包
<dependencies>
<!-- spring boot的核心包 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
三、创建应用程序类
package com.summer.test;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class WebApplication {
public static void main(String[] args) {
SpringApplication.run(WebApplication.class, args);
}
}
说明:应用程序类,放在业务类所在包的同级,这样才能使得业务类被扫描到。具体,如图一所示。
四、创建业务类
package com.summer.test.web.controller.test;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class SummerTest {
@RequestMapping("/")
String home() {
return "Hello World!";
}
@RequestMapping("/hello/{myName}")
String index(@PathVariable String myName) {
return "Hello " + myName + "!!!";
}
}
五、启动应用程序类
六、浏览器访问, 输入http://localhost:8080
总结:初次接触springboot,在具体的项目中总是依赖了很多的jar包,导致,我对springboot的核心jar包不清楚,故通过此例来验证jar包的功能。当然,仅通过一个例子,并不能说明说明问题,期待后续的继续学习吧。
阅读全文
0 0
- springboot项目搭建(一)
- SpringBoot(一):快速搭建一个springboot项目
- SpringBoot之1分钟快速搭建Web项目(一)
- 项目结构搭建【springboot mybatis个人博客系统(一)】
- springboot个人博客系统---搭建项目环境(一)
- springboot 构建(一)初步搭建springboot
- SpringBoot (一)环境搭建
- springboot(一)创建springboot项目
- springboot微服务搭建(一):搭建springboot框架
- springboot (1) 快速搭建简单项目
- springboot入门(一)--快速搭建一个springboot框架
- 快速搭建SpringBoot项目
- springBoot快速搭建项目
- Spring Boot 学习(一) 快速搭建SpringBoot 项目
- Spring Boot 学习(一) 快速搭建SpringBoot 项目
- SpringBoot搭建微服务(一)HelloWorld!
- QiYuAdmin-架构搭建一(SpringBoot实战)
- SpringBoot的入门搭建(一)
- sed,awk工具学习
- 【MyBatis学习13】MyBatis中的二级缓存
- 服务器源码安装TensorFlow
- android studio Error:(1, 1) 错误: 非法字符: '\ufeff' 解决方案
- C语言学习笔记——指针的作用
- springboot项目搭建(一)
- JS对象
- ubuntu16.04 安装 lib32readline-gplv2-dev 出错,解决办法
- 51nod1080 两个数的平方和
- bigchaindb源码分析(一)——命令行参数与配置文件解析
- C#从list里查找某个链表里的子项
- connect方法会阻塞,请问有什么方法可以避免其长时间阻塞?
- 基础知识
- hexo提交搜索引擎(百度+谷歌)