springboot~入门第一篇~
2021-07-20 00:07
标签:rop 项目 image oid round depend selection auto sele 首先新建个 maven 项目 Springboot就是个简单的maven 项目 设置下面参数(自己写) 用下面的pom.xml数据覆盖项目里的 再在src下创建一个Application.java文件(有点类似Jfinal里的run里的JfinalConfig启动文件) 创建一个HelloController.java(控制器)文件 再运行Application.java文件。 通过http://127.0.0.1:8080/hello 访问 看到 你就入门springboot啦 运行时 然而只是访问控制器是不够的,还得访问到页面。 待续... springboot~入门第一篇~ 标签:rop 项目 image oid round depend selection auto sele 原文地址:https://www.cnblogs.com/yizhizhangBlog/p/9514398.html
菜单 -> File -> New -> Other -> Maven -> Maven -> Maven Project -> New Maven Project
勾上这个 Create a simple project (skip archetype selection), 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.0modelVersion>
groupId>com.how2javagroupId>
artifactId>springbootartifactId>
version>0.0.1-SNAPSHOTversion>
name>springbootname>
description>springbootdescription>
parent>
groupId>org.springframework.bootgroupId>
artifactId>spring-boot-starter-parentartifactId>
version>1.5.9.RELEASEversion>
parent>
dependencies>
dependency>
groupId>org.springframework.bootgroupId>
artifactId>spring-boot-starter-webartifactId>
dependency>
dependency>
groupId>junitgroupId>
artifactId>junitartifactId>
version>3.8.1version>
scope>testscope>
dependency>
dependencies>
properties>
java.version>1.8java.version>
properties>
build>
plugins>
plugin>
groupId>org.springframework.bootgroupId>
artifactId>spring-boot-maven-pluginartifactId>
plugin>
plugins>
build>
project>
package springboot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
package springboot;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@RequestMapping("/hello")
public String hello() {
return "Hello Spring Boot!";
}
}