(一)Java版接口自动化-使用IntelliJ IDEA从0开始创建spring boot+maven项目
一、接口自动化框架图
二、使用IntelliJ IDEA创建spring boot+maven项目
1、新建 Spring Initializr 项目
2、填写Group、Artifact、Java Version
3、勾选spring web
4、默认工程名,项目路径根据自己的github选择即可
5、点击【Finish】,耐心等待下载对应的maven包
6、下载完成后,打开对应的工程文件
- InterfacetestApplication: 一个带有 main() 方法的类,用于启动应用程序
- InterfacetestApplicationTests:一个空的 Junit 测试了,它加载了一个使用 Spring Boot 字典配置功能的 Spring 应用程序上下文
- application.properties:一个空的 properties 文件,可以根据需要添加配置属性
- pom.xml: Maven 构建说明文件
7、测试下是否可以正常访问
新建一个HelloController
D:\github\interfacetest\src\main\java\com\automation\interfacetest\HelloController.java
package com.automation.interfacetest; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; /** * @title: * @author: 2022/1/717:09 * @date: 2022/1/717:09 */ @RestController public class HelloController { @RequestMapping("/hello") public String hello() { return "Hello Spring Boot!"; } }
由于我本地8080端口被占用,更改下端口号
D:\github\interfacetest\src\main\resources\application.properties
#设置服务端口
server.port=8888
运行Run InterfacetestApplication
没有报错,如下所示就算成功了,如果有端口冲突就换一个端口,默认端口:8080
在浏览器输入下面的访问地址:
http://localhost:8787/hello
页面展示如图所示,证明大功告成