diff --git a/backend/pom.xml b/backend/pom.xml index 561fe81516..ab143b2730 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -110,7 +110,6 @@ commons-codec commons-codec - 1.12 junit @@ -128,43 +127,12 @@ slf4j-simple - - - org.apache.jmeter - ApacheJMeter_http - ${jmeter.version} - - - org.apache.logging.log4j - log4j-slf4j-impl - - - - - - kg.apc - jmeter-plugins-tst - 2.5 - - - - kg.apc - jmeter-plugins-casutg - 2.9 - - com.opencsv opencsv 5.1 - - org.apache.httpcomponents - httpclient - 4.5.3 - - diff --git a/backend/src/main/java/io/metersphere/Application.java b/backend/src/main/java/io/metersphere/Application.java index 20ac59d613..693b24040f 100644 --- a/backend/src/main/java/io/metersphere/Application.java +++ b/backend/src/main/java/io/metersphere/Application.java @@ -6,8 +6,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.web.servlet.ServletComponentScan; -import org.springframework.context.annotation.Bean; -import org.springframework.web.client.RestTemplate; @SpringBootApplication(exclude = {QuartzAutoConfiguration.class}) @ServletComponentScan @@ -17,8 +15,5 @@ public class Application { SpringApplication.run(Application.class, args); } - @Bean - public RestTemplate restTemplate() { - return new RestTemplate(); - } + } diff --git a/backend/src/main/java/io/metersphere/config/WebConfig.java b/backend/src/main/java/io/metersphere/config/WebConfig.java index 35acc14672..1546184637 100644 --- a/backend/src/main/java/io/metersphere/config/WebConfig.java +++ b/backend/src/main/java/io/metersphere/config/WebConfig.java @@ -1,7 +1,9 @@ package io.metersphere.config; import io.metersphere.interceptor.TestInterceptor; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.web.client.RestTemplate; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @@ -12,4 +14,9 @@ public class WebConfig implements WebMvcConfigurer { public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(new TestInterceptor()); } + + @Bean + public RestTemplate restTemplate() { + return new RestTemplate(); + } } diff --git a/backend/src/main/java/io/metersphere/service/TestResourcePoolService.java b/backend/src/main/java/io/metersphere/service/TestResourcePoolService.java index 058c555d34..e81cc22944 100644 --- a/backend/src/main/java/io/metersphere/service/TestResourcePoolService.java +++ b/backend/src/main/java/io/metersphere/service/TestResourcePoolService.java @@ -16,7 +16,7 @@ import io.metersphere.dto.TestResourcePoolDTO; import io.metersphere.engine.kubernetes.provider.KubernetesProvider; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.http.HttpStatus; +import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -43,6 +43,8 @@ public class TestResourcePoolService { private TestResourceMapper testResourceMapper; @Resource private ExtTestReourcePoolMapper extTestReourcePoolMapper; + @Resource + private RestTemplate restTemplate; public TestResourcePoolDTO addTestResourcePool(TestResourcePoolDTO testResourcePool) { testResourcePool.setId(UUID.randomUUID().toString()); @@ -100,9 +102,8 @@ public class TestResourcePoolService { private boolean validateNode(NodeDTO node) { try { - RestTemplate restTemplate = new RestTemplate(); ResponseEntity entity = restTemplate.getForEntity(String.format(nodeControllerUrl, node.getIp(), node.getPort()), String.class); - return entity.getStatusCode().value() == HttpStatus.SC_OK; + return HttpStatus.OK.equals(entity.getStatusCode()); } catch (Exception e) { return false; }