0
点赞
收藏
分享

微信扫一扫

spring boot--最基础的hello world

倪雅各 2022-07-12 阅读 60


最基础的hello world:

项目目录结构:

spring boot--最基础的hello world_spring

卷 software_home 的文件夹 PATH 列表
卷序列号为 7E58-1E96
D:.
│ .txt
│ pom.xml
│ springboot_0_hello.iml

├─.idea
│ compiler.xml
│ encodings.xml
│ misc.xml
│ uiDesigner.xml
│ workspace.xml

├─src
│ ├─main
│ │ ├─java
│ │ │ └─com
│ │ │ └─swq
│ │ │ HelloController.java
│ │ │ Helloworld.java
│ │ │
│ │ └─resources
│ └─test
│ └─java
└─target
│ springboot_0_hello-1.0-SNAPSHOT.jar
│ springboot_0_hello-1.0-SNAPSHOT.jar.original

├─classes
│ └─com
│ └─swq
│ HelloController.class
│ Helloworld.class

├─generated-sources
│ └─annotations
├─maven-archiver
│ pom.properties

└─maven-status
└─maven-compiler-plugin
├─compile
│ └─default-compile
│ createdFiles.lst
│ inputFiles.lst

└─testCompile
└─default-testCompile
inputFiles.lst

spring boot--最基础的hello world_maven_02

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>org.example</groupId>
<artifactId>springboot_0_hello</artifactId>
<version>1.0-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>


</project>

Helloworld:

package com.swq;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Helloworld {
public static void main(String[] args) {
SpringApplication.run(Helloworld.class, args);
}

}

HelloController:

package com.swq;


import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class HelloController {
@ResponseBody
@RequestMapping("/hello")
public String hello(){
return "hello swq !";
}
}

 

 

 

打成jar包,直接CMD界面运行:

spring boot--最基础的hello world_xml_03

运行:

spring boot--最基础的hello world_spring_04

spring boot--最基础的hello world_xml_05

访问:

spring boot--最基础的hello world_maven_06

 

OK! 

举报

相关推荐

0 条评论