Selenium 更换弹簧护套上的端口
我试图通过编写以下代码来更改spring boot中使用的端口 但应用程序并没有改变端口 2017年7月13日下午7:20:18 org.openqa.selenium.safari.SafariDriverServer启动信息:服务器 于港口38002 2017年7月13日下午7:20:18开始 org.openqa.selenium.safari.SafariDriverCommandExecutor启动信息: 发射狩猎 我必须做什么才能激活此代码Selenium 更换弹簧护套上的端口,selenium,spring-boot,Selenium,Spring Boot,我试图通过编写以下代码来更改spring boot中使用的端口 但应用程序并没有改变端口 2017年7月13日下午7:20:18 org.openqa.selenium.safari.SafariDriverServer启动信息:服务器 于港口38002 2017年7月13日下午7:20:18开始 org.openqa.selenium.safari.SafariDriverCommandExecutor启动信息: 发射狩猎 我必须做什么才能激活此代码 尝试使用位于src/main/resour
尝试使用位于
src/main/resources的application.properties
文件设置服务器端口
server.port=9000
在Spring Boot中设置服务器端口有多种方法
1) 在src/main/resources
中的application.properties
中设置它:server.port=8888
2) 在application.yaml中:
服务器:
端口:8888
3) 动态作为系统属性:system.setProperty(“server.port”,80)代码>
4) 引导应用程序时,例如-Dserver.port=8888
5) 出于测试目的(我看到您添加了标记selenium,我想您希望在此应用程序上运行一些测试),您需要向测试类添加注释:
@SpringBootTest(webEnvironment=SpringBootTest.webEnvironment.DEFINED\u PORT)
@TestPropertySource(properties=“server.port=8888”)
server.port=9000