web入门,软件IntelliJ IDEA,maven

web入门,软件IntelliJ IDEA,maven

1.新建文件
new module
选择Spring Initializr

Type 选择 maven language 选择Java
Group 更改自己的项目名称为com.itheima ,
Aetifact 更改为自己的名称 springboot-web-quickstart

Java选择为11
点击Next

选择Spring Boot为稳定版2.7.15

在左侧Dependencies中选择 web -> 单击Spring web框

src->main->java->com.itheima. springboot-web-quickstart ->controller文件夹下点击new -JavaClass 新建JAVA类hellocontroller

文件创建完成。

2.文件介绍
1pom.xml

org.springframework.boot
spring-boot-starter-parent
2.7.15

<groupId>com.itheima</groupId>
<artifactId>springboot-web-quickstart</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>springboot-web-quickstart</name>
<description>springboot-web-quickstart</description>
<properties>
	<java.version>11</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>
org.springframework.boot spring-boot-maven-plugin 2. src->main->java->com.itheima. springboot-web-quickstart -文件夹下的 SpringbootWebQuickstart1Application文件 //启动类。启动springboot工程 @SpringBootApplication public class SpringbootWebQuickstart1Application {
public static void main(String[] args) {
    SpringApplication.run(SpringbootWebQuickstart1Application.class, args);
}

}

从此main对项目启动
3.hellocontroller类文件
//请求处理类
@RestController
public class hellocontroller {
@RequestMapping(“/hello”) //映射,绑定关键字/hello
public String hello(){ //主要操作
System.out.println(“Hello world”);
return “hello world”;
}

}
// 两个@会自动弹出相关的import
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

3项目执行
SpringbootWebQuickstart1Application文件点击主函数操作后,spring项目执行,端口为8080.
登录网址 http://localhost:8080/hello
网址执行输出hello world
IntelliJ IDEA也输出 hello world

入门结束

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值