[英]How to get a file from WEB-INF from a static method in the test directory on a appengine-app
I'm trying to read from the web-inf directory on a static method on a test 我正在尝试从静态的方法上的web-inf目录读取
public static void getSource(){
File file = Paths.get("src/main/webapp/WEB-INF/schemas/tmp.json").toFile();
}
I get this error: 我收到此错误:
java.nio.file.Paths is not supported by Google App Engine's Java runtime environment
classes which are not supported by Google App Engine's Java runtime environment could not be used also for tests? Google App Engine的Java运行时环境不支持的类也不能用于测试吗?
if so how can I read from the WEB-INF directry on a test from a static method? 如果是这样,如何从静态方法的测试中从WEB-INF指令中读取?
add on the pom
file: 在
pom
文件上添加:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>2.5.6</version>
<scope>test</scope>
</dependency>
and then use this: 然后使用:
InputStream inputStream = new FileSystemResource("src/main/webapp/WEB-INF/schemas/tmp.json").getInputStream();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.