简体   繁体   English

如何通过appengine-app的测试目录中的静态方法从WEB-INF获取文件

[英]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.

相关问题 如何在JUNIT测试中从WEB-INF获取文件 - How to get a file from WEB-INF in a JUNIT test 如何从Web存档的WEB-INF目录加载StringTemplateGroups - How to load StringTemplateGroups from the WEB-INF directory of a web archive 如何从Web存档的WEB-INF目录加载资源 - How to load a resource from WEB-INF directory of a web archive 如何从WEB-INF / classes目录中的类写入WebContent目录中的文件 - How to write to a file in WebContent directory from a class in WEB-INF/classes directory 如何从WEB-INF目录加载文件/属性? - How to load files/properties from WEB-INF directory? 如何从引用java项目访问静态资源(WEB-INF)文件夹中的文件? - How to access file in the static resources(WEB-INF) folder from the referencing java project? 如何从WEB-INF读取db.properties文件 - How to Read db.properties File from WEB-INF 如何获取WebContent / WEB-INF / classes目录的路径 - How to get path to WebContent/WEB-INF/classes directory 可以从WEB-INF \\ lib \\ {*。jar} \\ META-INF \\ resources \\ WEB-INF目录访问tld文件吗? - Can tld files be accessed from WEB-INF\lib\{*.jar}\META-INF\resources\WEB-INF directory? 尝试从测试方法读取WEB-INF内的软件包时,缺少MissingPackageNameException - MissingPackageNameException when trying to read a package inside WEB-INF from test method
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM