本文整理匯總了Java中org.springframework.core.io.ClassPathResource.exists方法的典型用法代碼示例。如果您正苦於以下問題:Java ClassPathResource.exists方法的具體用法?Java ClassPathResource.exists怎麽用?Java ClassPathResource.exists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.core.io.ClassPathResource
的用法示例。
在下文中一共展示了ClassPathResource.exists方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: checkGrouperAttributes
import org.springframework.core.io.ClassPathResource; //導入方法依賴的package包/類
@Test
public void checkGrouperAttributes() {
final ClassPathResource resource = new ClassPathResource("grouper.client.properties");
if (resource.exists()) {
final GrouperRegisteredServiceAccessStrategy strategy = new GrouperRegisteredServiceAccessStrategy();
final Map<String, Set<String>> requiredAttributes = new HashMap<>();
requiredAttributes.put("memberOf", Collections.singleton("admin"));
strategy.setRequiredAttributes(requiredAttributes);
strategy.doPrincipalAttributesAllowServiceAccess("banderson", (Map) TestUtils.getTestAttributes());
} else {
logger.info("{} is not configured. Skipping tests", resource.getFilename());
}
}
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:14,代碼來源:GrouperRegisteredServiceAccessStrategyTests.java
示例2: checkGrouperAttributes
import org.springframework.core.io.ClassPathResource; //導入方法依賴的package包/類
@Test
public void checkGrouperAttributes() {
final ClassPathResource resource = new ClassPathResource("grouper.client.properties");
if (resource.exists()) {
final GrouperRegisteredServiceAccessStrategy strategy = new GrouperRegisteredServiceAccessStrategy();
final Map<String, Set<String>> requiredAttributes = new HashMap<>();
requiredAttributes.put("memberOf", Collections.singleton("admin"));
strategy.setRequiredAttributes(requiredAttributes);
strategy.doPrincipalAttributesAllowServiceAccess("banderson", (Map) RegisteredServiceTestUtils.getTestAttributes());
} else {
LOGGER.info("[{}] is not configured. Skipping tests", resource.getFilename());
}
}
示例3: getClassOrSystemPath
import org.springframework.core.io.ClassPathResource; //導入方法依賴的package包/類
/**
* 獲取文件的絕對路徑,class查找和係統路徑查找
*/
public static String getClassOrSystemPath(String path) {
ClassPathResource rs = new ClassPathResource(path);
FileSystemResource fr = new FileSystemResource(path);
if (rs.exists())
return FileUtils.class.getClassLoader().getResource(path).getFile();
if (fr.exists())
return fr.getPath();
return null;
}
示例4: loadImportView
import org.springframework.core.io.ClassPathResource; //導入方法依賴的package包/類
private String loadImportView() throws IOException
{
ClassPathResource importViewResource = new ClassPathResource(configPath + packageName + ".xml");
if (!importViewResource.exists())
{
throw new AlfrescoRuntimeException("Cannot find site config " + importViewResource.getPath());
}
return convert(importViewResource.getInputStream());
}