Tag: spring

在Docker中不能链接Consul和Spring Boot应用程序

我有以下configuration的Spring Boot应用程序: spring: thymeleaf: cache: false cloud: consul: host: consul port: 8500 discovery: prefer-ip-address: true instanceId: ${spring.application.name}:${spring.application.instance_id:${random.value}} 我想运行docker-compose(Docker 1.11.2,docker-compose 1.7.1): consul: image: progrium/consul:latest container_name: consul hostname: consulhost ports: – "8400:8400" – "8500:8500" – "8600:53" command: "-server -bootstrap-expect 1 -ui-dir /ui" collector-server: container_name: collector-server image: io.thesis/collector-server ports: – "9090:9090" links: – consul:consul 不幸的是,这是行不通的,我得到:com.ecwid.consul.transport.TransportException:java.net.ConnectException:连接被拒绝。 我完全不知道为什么它不能连接到Consul,因为我可以用这种方式连接到其他系统,例如rabbitmq。 谢谢你的任何想法!

Spring Cloud如何与Docker Swarm相关

我对Docker Swarm和Spring Cloud等云/集群技术以及它们之间的相互关系感到困惑。 它是不是正确的方法,他们在不同的层次上实现相同的function? 例如,docker swarm在容器或networking层执行负载平衡和服务发现(应用程序不知道这个层),像Spring Cloud这样的框架将这个逻辑embedded到应用程序中,给予更多的灵活性,但也违反了关注点的分离。 我错了,还是这是正确的? 每种方法的SWOT是什么?是否有理由同时使用Docker工具和Spring Cloud实用工具?

我如何通过Kubernetespipe理的Docker容器连接到JMX?

我正尝试使用客户端(如JConsole,Java Mission Control或Java)连接到我的Java应用程序(Java 8和Spring Boot 1.4和Tomcat)上定义的1099(默认情况下)的JMX端口VisualVM,但我遇到一个错误: java.rmi.ConnectException: Connection refused to host: 10.xxx.xxx.xx, nested exception is: java.net.ConnectException: Connection timed out … 请注意,我隐藏了确切的主机IP,但它是我的服务部署在特定Kubernetespipe理的Docker容器的Pod IP。我尝试使用以下服务URL连接到JMX端口: jconsole service:jmx:rmi://<nodeIP>:<nodePort>/jndi/rmi://<nodeIP>:<nodePort>/jmxrmi 我知道JMX会打开一个随机的高端口 ,我试图通过包含一个自定义的@Configuration类来强制这个高端口也服务于端口1099 。 我已经进入了实际的容器和荚运行 netstat -tulpn 看到打开的端口,我已经证实,唯一打开的端口是8443(我的应用程序正在运行)和1099(JMX端口); 这表明我的class级工作。 我还确保端口1099在Kubernetes方面是开放的,所以这不是什么阻塞它。 由于围绕JMX远程连接的许多答案都有build议,所以我尝试了以下Java选项的许多变体,但都无济于事: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.jmi.port=1099 -Djava.rmi.server.hostname=0.0.0.0 答案build议强制JMX端口和RMIregistry端口是相同的,但没有一个工作。 我认为这个问题可能是因为主机名(我尝试使用-Djava.rmi.server.hostname = 0.0.0.0进行dynamic化)无法parsing为每次部署服务时创build的不同主机名(pod IP) 。 因此,看起来连接无法完成,因为在部署服务后,JMX无法查看Kubernetes分配的主机名。 有没有办法让JMX识别Kubernetes主机名? 或者,有没有其他方式通过Kubernetes部署的服务远程连接到JMX端口? 编辑1:我已经做了一些额外的研究,也许一个可选的JMXMP而不是RMI可能工作? 有没有人得到这个与Tomcat的工作?

“org.springframework.beans.factory.UnsatisfiedDependencyException:创buildbean时出错”使用docker

我正在试图让docker运行在我的AWS上,并使用docker-compose。 我运行一个maven构build,一切都成功,但是当我做docker-compose,我得到这个假装exception,说我的businessDelegate不是自动assembly,因为我的假装服务得到一个参数0 这是我的代表class @Component public class BusinessDelegateImpl implements BusinessDelegate{ private ShippingService shippingService; @Autowired public void setShippingService(ShippingService shippingService) {this.shippingService = shippingService;} /**More Methods below**/ } 简单的权利? 就我所见,一切正确。 这是我的假装客户端类 @FeignClient("shipping") public interface ShippingService { @RequestMapping(value = "/insert", method = RequestMethod.POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE) ResponseEntity<Shipping> insert(@RequestBody Shipping shipping); @RequestMapping(value = "/save", method = RequestMethod.PUT, produces […]

将外部application.properties文件添加到tomcat中的dockerized spring启动web应用程序

tomcat / webapps文件夹里有我的spring启动web应用程序的tomcat的docker镜像。 该应用程序在文件夹中打包了自己的application.properties文件。 我想给运行docker映像的任何人安装它自己的外部application.properties文件 ,供Spring Boot Web App运行。 这怎么能完成呢? 非常感谢你

Docker中的Spring Boot静态文件夹

在Spring Boot项目中,我必须将默认位置更改为资源文件夹。 我使用这个代码来实现想要的结果: @Bean WebMvcConfigurer configurer () { return new WebMvcConfigurerAdapter() { @Override public void addResourceHandlers (ResourceHandlerRegistry registry) { String location = "file:" + System.getProperty("user.dir") + "/pictures/"; registry.addResourceHandler("/pictures/**"). addResourceLocations(location); super.addResourceHandlers(registry); } }; } 在我的本地机器上翻转作品。 当创buildDocker镜像并运行它时,似乎没问题,但是当我尝试请求目录中的某些文件时,它会引发此exception: 2017-08-23 13:03:48.652 ERROR 8 — [nio-8080-exec-1] oaccC[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception java.net.UnknownHostException: […]

Spring Boot +带有Docker的DynamoDB Local:连接到localhost:8000失败

我构build了一个查询DynamoDB的Spring Boot REST API,我想configuration一个或两个作为微服务运行的Docker容器:一个在本地运行DynamoDB,另一个运行REST API。 我为Spring Boot REST APIconfiguration了一个容器,但是当我调用API时,即使DynamoDB在localhost:8000上运行,也无法查询本地DynamoDB。 我得到的错误是: Unable to execute HTTP request: Connect to localhost:8000 [localhost/127.0.0.1] failed: Connection refused (Connection refused) 尽pipe得到这个消息,我可以使用我的浏览器通过本地主机访问DynamoDB。 就好像Docker容器不允许API访问localhost:8000,即使API容器在localhost:8080上运行。 我应该如何configuration我的容器,使每个运行作为一个单独的微服务? 有没有人见过类似的问题?

Docker上的Spring Boot Admin在Docker上看不到其他应用程序

我有一个简单的Spring Boot Admin应用程序在Docker上运行。 我的问题是它显示在Docker上运行的其他应用程序脱机。 在别处运行的应用程序显示得很好。 任何人都可以帮助和告诉我如何configuration或添加到应用程序? 提前致谢 编辑:问题是与泊坞窗,其他应用程序运行类似的configuration在线pipe理应用程序,只有docker的人不是 编辑2:错误:{“时间戳”:1506501630423,“状态”:500,“错误”:“内部服务器错误”,“例外”:“com.netflix.zuul.exception.ZuulException”,“消息”:“连接到IP_ADDRESS]失败:连接超时“}

如何在Docker容器中configurationspring cloud oauth2

我遇到了一些微泉docker问题,我想可能是sso token-url不正确。 演示https://github.com/keryhu/micro-oauth2-docker 在本地计算机上,sso服务和auth服务工作正常。 但不是在docker集装箱, 问题是redirect到auth-server超时。 SSO(pc-gateway服务)application.yml: security: user: password: none oauth2: client: accessTokenUri: http://${AUTHSERVER_PORT_9999_TCP_ADDR:localhost}:9999/uaa/oauth/token userAuthorizationUri: http://${AUTHSERVER_PORT_9999_TCP_ADDR:localhost}:9999/uaa/oauth/authorize 泊坞窗,compose.yml eureka: image: eureka:0.0.1-SNAPSHOT container_name: eureka hostname: eureka ports: – "8761:8761" configserver: image: config-server:0.0.1-SNAPSHOT container_name: configserver hostname: configserver links: – eureka ports: – "8888:8888" authserver: image: auth-server:0.0.1-SNAPSHOT container_name: authserver hostname: authserver links: – eureka – configserver ports: – […]

客户端证书和Docker的FeignClient

我有一个要求我的微服务利用双向ssl。 每个微服务都是Spring Boot Application,注释如下: @SpringBootApplication @EnableFeignClients @EnableDiscoveryClient @EnableZuulProxy public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } } 每个yml都有类似于eureka / ribbon的configuration: eureka: client: service-url: defaultZone: ${EUREKA_CLIENT_SERVICEURL_PROTOCOL:http}://${EUREKA_CLIENT_SERVICEURL_HOST:192.168.99.100}:${EUREKA_CLIENT_SERVICEURL_PORT:8761}/eureka/ instance: secure-virtual-host-name: ${spring.application.name} prefer-ip-address: true non-secure-port-enabled: ${EUREKA_NON_SECURE_PORT_ENABLED:false} secure-port-enabled: ${EUREKA_SECURE_PORT_ENABLED:true} secure-port: ${server.port} ribbon: IsSecure: true eureka: enabled: true 每个微服务都有一个控制器,为各种function公开api。 当一个微服务需要调用另一个微服务端点时,我试图通过创build该微服务的客户端接口来实现: @FeignClient(name = "user", configuration = FeignConfiguration.class, […]