我是Docker的新手,目前还不清楚如何从容器访问外部数据库.是连接字符串中硬编码的最佳方法吗?
# Dockerfile
ENV DATABASE_URL amazon:rds/connection?string
Run Code Online (Sandbox Code Playgroud) 我想知道在处理通过网络传输对象时我们应该选择什么序列化机制.优缺点都有什么 ?
我知道大多数的我们在使用的时候JSON还是XML用于AJAX自传输格式相当多Javascript格式,再加上JSON是相当轻巧的,其占用空间小,因此是Java系列化完全出表的?
java serialization json xml-serialization data-serialization
所以这是实施..
public ConcurrentMap<String , ConcurrentMap<String, Object>> map = new ConcurrentHashMap<>();
public void put(String subKey, String key, Object value) {
map.putIfAbsent(subKey, new ConcurrentHashMap<>());
map.get(subKey).put(key, value);
}
public Object get(String subKey, String key) {
return map.get(subKey) == null ? null : map.get(subKey).get(key);
}
Run Code Online (Sandbox Code Playgroud)
Put 看起来是线程安全的
感谢您的任何澄清
我在Spring Boot(版本1.5.9.RELEASE)项目中使用了swagger 2.0。Swagger可以正常工作,但是现在文档有数百个api,我想重定向文档到不同的URL。
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket postsApi() {
return new Docket(DocumentationType.SWAGGER_2).groupName("public-api")
.apiInfo(apiInfo()).select().paths(postPaths()).build();
}
private Predicate<String> postPaths() {
return or(regex("/api/posts.*"), or(regex("/api/.*"), regex("/secure/api/.*")));
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder().title("Swagger API")
.description("Swagger Integration with Spring Boot")
.termsOfServiceUrl(null)
.license(null)
.licenseUrl(null).version("1.0").build();
}
}
Run Code Online (Sandbox Code Playgroud)
请提出任何建议。提前致谢。
java ×2
docker ×1
dockerfile ×1
hashmap ×1
json ×1
spring ×1
spring-boot ×1
swagger ×1
swagger-2.0 ×1