cn.hutool.core.io.resource.ClassPathResource Java Examples

The following examples show how to use cn.hutool.core.io.resource.ClassPathResource. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LoadData.java    From janusgraph-visualization with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
    ClassPathResource classPathResource = new ClassPathResource("janusgraph.properties");
    File file = classPathResource.getFile();
    String path = file.getPath();
    JanusGraph graph = JanusGraphFactory.open(path);
    GraphTraversalSource g = graph.traversal();
    g.V().drop().iterate();
    g.tx().commit();
    graph.tx().commit();
    GraphOfTheGodsFactory.load(graph);
    graph.close();
}
 
Example #2
Source File: HutoolController.java    From mall-learning with Apache License 2.0 5 votes vote down vote up
@ApiOperation("ClassPathResource使用:在classPath下查找文件,在Tomcat等容器下,classPath一般是WEB-INF/classes")
@GetMapping("/classPath")
public CommonResult classPath() throws IOException {
    //获取定义在src/main/resources文件夹中的配置文件
    ClassPathResource resource = new ClassPathResource("generator.properties");
    Properties properties = new Properties();
    properties.load(resource.getStream());
    LOGGER.info("/classPath:{}", properties);
    return CommonResult.success(null, "操作成功");
}
 
Example #3
Source File: BeanConfig.java    From WeBASE-Codegen-Monkey with Apache License 2.0 4 votes vote down vote up
/**
 * Load class path resource.
 * 
 * @return ClassPathResource
 */
@Bean
@Profile("!test")
public ClassPathResource getClassPathResource() {
    return new ClassPathResource("application.properties");
}
 
Example #4
Source File: BeanConfig.java    From WeBASE-Codegen-Monkey with Apache License 2.0 4 votes vote down vote up
@Bean
@Profile("test")
public ClassPathResource getTestClassPathResource() {
    return new ClassPathResource("application-test.properties");
}