在主类中返回新的rest模板有什么好处?
我有正确的认识吗?
从我在主类中注册Bean restTemplate的理解来看,我们基本上是预先注册的,然后每次在其他类中使用Rest模板字段时,Spring都会自动从容器中获取它。
@SpringBootApplication
public class App {
@Bean
RestTemplate restTemplate() {
return new RestTemplate();
}
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}
Run Code Online (Sandbox Code Playgroud) 在线浏览,找不到如何编写检查返回类型(字符串)的测试
@Test
public void testExtractText(){
String result = myPdf().extractText();
Assert.assertThat();
}
Run Code Online (Sandbox Code Playgroud)