Tag: java

Gson:如何从没有注释的序列化中排除特定的字段

我正在努力学习Gson,而我正在努力解决现场排斥问题。 这是我的课程 public class Student { private Long id; private String firstName = "Philip"; private String middleName = "J."; private String initials = "PF"; private String lastName = "Fry"; private Country country; private Country countryOfBirth; } public class Country { private Long id; private String name; private Object other; } 我可以使用GsonBuilder并添加ExclusionStrategy像字段名称像firstName或country但我似乎无法设法排除像country.name这样的特定字段的属性。 使用方法public boolean shouldSkipField(FieldAttributes fa) […]

无法将dockerized spring boot应用程序连接到dockerized postgre sql

我有一个docker-compose.yml有两个服务: version: '2' services: stuffer: container_name: stuffer_container build: . ports: – "8080:8080" environment: – spring.profiles.active=dev depends_on: – postgreDB postgreDB: container_name: postgreDB_container image: "postgres:9.6.2" ports: – "5432:5432" expose: – "5432" environment: – POSTGRES_DB=stuffer – POSTGRES_USER=postgres – POSTGRES_PASSWORD=root123 volumes: – /home/iwaneez/postgreData:/var/lib/postgresql/data 我的应用程序有application-dev.properties: ## Datasource config spring.datasource.driver-class-name=org.postgresql.Driver spring.datasource.url=jdbc:postgresql://postgreDB:5432/stuffer spring.datasource.username=postgres spring.datasource.password=root123 当我运行他们都使用 码头工人组成 我得到连接拒绝异常: stuffer_container | Caused by: org.springframework.jdbc.datasource.init.UncategorizedScriptException: […]

在Docker容器上运行时,没有找到HTTP请求的映射

Spring Security安装Spring Boot api到目前为止运行良好。 当我尝试从Docker容器运行api时遇到问题,当接收到像http:// localhost:8080 / api / v1 / h2-console /这样的请求时,我得到一个没有找到HTTP请求的映射。 这是直接在jvm上运行应用程序的日志一切正常: 2017-07-22 19:28:36.310 DEBUG 6235 — [nio-8080-exec-1] osswaiFilterSecurityInterceptor : Authorization successful 2017-07-22 19:28:36.310 DEBUG 6235 — [nio-8080-exec-1] osswaiFilterSecurityInterceptor : RunAsManager did not change Authentication object 2017-07-22 19:28:36.310 DEBUG 6235 — [nio-8080-exec-1] ossecurity.web.FilterChainProxy : /h2-console/ reached end of additional filter chain; proceeding with […]

Docker组合和Spring Boot Config服务器

我有一个工作的春季启动Web应用程序,从春季启动配置服务器获取其配置属性。 我的应用程序有3个环境 – dev,qa和prod。 在我的资源文件夹中,我有3个文件bootstrap-dev.properties,bootstarp-qa.properties和bootstrap-prod.properties。 示例引导文件如下所示 spring.application.name=MyApp spring.cloud.config.uri=http://my.config.server spring.cloud.config.label=feature-branch-101 spring.output.ansi.enabled=ALWAYS spring.profiles.active=dev 我需要将什么内容放在我的docker-compose文件中,该文件可以从spring启动配置服务器读取配置,并支持3种不同的环境。 有没有人有样品?

Spring&Docker:RMI主机名解析为0.0.0.0,而不是其预期的IP地址

我目前正在开发一个将Docker和Spring程序与RMI服务相关联的项目,而我找不到解决问题的方法。 我试图通过docker-compose.yml文件将两个Spring程序部署到两个不同的容器中。 第一个暴露了地址为0.0.0.0 (全部)的RMI接口以及特定的端口(在Docker文件中也是EXPOSEd)。 而第二个只是一个使用远程接口的RMI客户端。 为了访问公开RMI服务的容器,我通过Compose文件中的links参数给它一个别名,如下所示: services: rmi-service: … rmi-client: … links: – rmi-service:rmihost 当我用docker-compose up -d启动我的容器时,如果我从第二个容器执行命令ping rmihost ,它工作的很好。 但是当我尝试启动我的Spring RMI客户端时,出现以下错误: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'my.rmi.client' defined in class path resource [META-INF/rmi-client-spring.xml]: Invocation of init method failed; nested exception is org.springframework.remoting.RemoteConnectFailureException: Could not connect to remote service [rmi://rmihost:11199/businessService]; nested exception is java.rmi.ConnectException: Connection […]