Jackrabbit 简单的CRUD 操作的实例

从实例中学习Jackrabbit这一JCR开源项目。
java 代码
 
  1. public static void main(String[] args) {  
  2. // 定义文件库的地址。  
  3. System.setProperty("org.apache.jackrabbit.repository.home""C:/temp/repository");  
  4. // 建立一个零时的内容库,这种方法只是用于测试使用,商业使用时仍然需要配置Config.xml文件信息。  
  5. Repository repository = new TransientRepository();  
  6. Session session = repository.login(new SimpleCredentials("maqujun",  
  7.         "maqujun".toCharArray()));  
  8. // 在根节点下创建子节点。  
  9. Node newNode = session.getRootNode().addNode("NewNode");  
  10. newNode.setProperty("maqujun""handsome");  
  11. session.save();  
  12.   
  13. // 查询已有节点属性内容  
  14. Node existNode = session.getRootNode().getNode("NewNode");  
  15. System.out.println("maqujun is " + existNode.getProperty("maqujun").getString());  
  16. newNode.setProperty("maqujun""very handsome");  
  17. session.save();  
  18.   
  19. // 更新JCR节点属性内容。   
  20. Node updatedNode = session.getRootNode().getNode("NewNode");  
  21. System.out.println("maqujun is " + updatedNode.getProperty("maqujun").getString());  
  22.           
  23. // 删除JCR节点    
  24. updatedNode.remove();  
  25. session.save();  
  26. }  

以上就是最简单的JCR CRUD操作的实现方式。当然在实际运用中我们会运用到更复杂的内容。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
提示错误[ERROR] [ERROR] Some problems were encountered while processing the POMs: [ERROR] Unresolveable build extension: Plugin org.apache.maven.wagon:wagon-webdav-jackrabbit:1.0-beta-6 or one of its dependencies could not be resolved: The following artifacts could not be resolved: commons-httpclient:commons-httpclient:jar:3.1 (absent): Could not transfer artifact commons-httpclient:commons-httpclient:jar:3.1 from/to central (https://repo.maven.apache.org/maven2): Connect to repo.maven.apache.org:443 [repo.maven.apache.org/146.75.112.215] failed: connect timed out @ @ [ERROR] The build could not read 1 project -> [Help 1] [ERROR] [ERROR] The project org.drools:droolsjbpm-integration:7.74.0-SNAPSHOT (D:\droolsjbpm-integration-main\droolsjbpm-integration-main\pom.xml) has 1 error [ERROR] Unresolveable build extension: Plugin org.apache.maven.wagon:wagon-webdav-jackrabbit:1.0-beta-6 or one of its dependencies could not be resolved: The following artifacts could not be resolved: commons-httpclient:commons-httpclient:jar:3.1 (absent): Could not transfer artifact commons-httpclient:commons-httpclient:jar:3.1 from/to central (https://repo.maven.apache.org/maven2): Connect to repo.maven.apache.org:443 [repo.maven.apache.org/146.75.112.215] failed: connect timed out -> [Help 2] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException [ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/PluginManagerException
最新发布
06-09

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值