热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

springboot集成geoservermanager

1、pom.xml 依赖 it.geosolutionsgeoserver-manager1.7.0 2、application.properties 配置信息geoserver.url= h

1、pom.xml 依赖

it.geosolutionsgeoserver-manager1.7.0

2、application.properties 配置信息

geoserver.url= http://localhost:8080/geoserver
geoserver.username= admin
geoserver.password= geoserver

3、GeoServerProperties.java 读取配置

@Data
@Configuration
@ConfigurationProperties(prefix = "geoserver")
public class GeoServerProperties {private String url;private String username;private String password;
}

4、GeoServerConfig.java 注入(核心)

@Configuration
public class GeoServerConfig {@Autowiredprivate GeoServerProperties geoServerProperties;@Beanpublic GeoServerRESTManager geoServerRESTManagerFactory() {try {return new GeoServerRESTManager(new URL(geoServerProperties.getUrl()), geoServerProperties.getUsername(),geoServerProperties.getPassword());} catch (Exception ex) {ex.printStackTrace();return null;}}
}

5、测试类

@SpringBootTest
public class GeoServerConfigTest {@Autowiredprivate GeoServerRESTManager geoServerRESTManager;@Testvoid testPublishTif() throws Exception {GeoServerRESTReader geoServerRESTReader = geoServerRESTManager.getReader();String workspace = "xiaozhai";boolean workspaceNull = geoServerRESTReader.existsWorkspace(workspace);System.out.println("workspace是否存在:" + workspaceNull);}
}

















推荐阅读
author-avatar
淡然的可欣
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有