创建SpringBoot工程
基于Spring官方骨架,创建SpringBoot工程。
基本信息描述完毕之后,勾选web开发相关依赖。
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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-parent</artifactId>
- <version>3.5.7</version>
- <relativePath/> <!-- lookup parent from repository -->
- </parent>
- <groupId>com.jinhei</groupId>
- <artifactId>demo01</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- <name>demo01</name>
- <description>demo01</description>
- <url/>
- <licenses>
- <license/>
- </licenses>
- <developers>
- <developer/>
- </developers>
- <scm>
- <connection/>
- <developerConnection/>
- <tag/>
- <url/>
- </scm>
- <properties>
- <java.version>21</java.version>
- </properties>
- <dependencies>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-web</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-test</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
-
- </project>
复制代码 HelloController
- package com.jinhei;
-
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
-
- @RestController
- public class HelloController {
- @RequestMapping("/hello")
- public String hello(String name){
- return "Hello" + name;
- }
- }
复制代码 访问:http://localhost:8080/hello?name=zidiu.com
综合项目:
JavaWeb(SpringBoot3+vue3)开发+教学管理系统项目实战
|