我做了一些更改来激活斜线编码的URL,for details它工作正常,我想在运行IT测试时激活这些更改。
如何在UserserviceApplication上激活这些更改。
@SpringBootApplication
@EnableDiscoveryClient
@EnableCaching
public class UserserviceApplication implements WebMvcConfigurer {
public static void main(String[] args) {
System.setProperty("org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH", "true");
SpringApplication.run(UserserviceApplication.class, args);
}
public void configurePathMatch(PathMatchConfigurer configurer) {
UrlPathHelper urlPathHelper = new UrlPathHelper();
urlPathHelper.setUrlDecode(false);
configurer.setUrlPathHelper(urlPathHelper);
}
}
@ActiveProfiles("it")
@RunWith(SpringRunner.class)
@TestPropertySource(locations = "classpath:application-it.properties")
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class TeamControllerIT {
@LocalServerPort private int port;
@Autowired private Environment environment;
1条答案
按热度按时间zpjtge221#
下面是我准备的工作代码。其中一个要点是setUrlEncodingEnabled()和urlEncodingEnabled()。您也可以检查以下链接CustomAppContext RestAssure URL Encoding