Tag: spring

如何提供application.properties文件来popup启动docker镜像作为input

我有spring启动docker的形象。 我在application.properties文件中提供了所有参数(环境variables)。 如何通过docker image作为input运行应用程序时提供这个文件。 请帮帮我。

Docker快速入门terminal给JAVA_HOMEvariables在使用maven时没有被正确的定义

我遵循本指南: https : //spring.io/guides/gs/spring-boot-docker/ 几天前,我使用./mvnw install dockerfile成功构build了一个dockerimage:使用虚拟工具箱for Windows,在Docker快速入门terminal内的克隆源表单上构build。 但现在重复执行相同的程序,每个在该terminal内执行的maven命令失败: The JAVA_HOME environment variable is not defined correctly This environment variable is needed to run this program NB: JAVA_HOME should point to a JDK not a JRE 如果有任何帮助,我正在使用Windows 10。 在cmd中可以执行mvn命令和java命令。 这种行为如何改变?我该如何解决这个问题?

Spring启动docker mount共享logbackconfiguration文件

我有一个微型服务架构的春季启动应用程序。 像10弹簧启动容器运行。 加载我打算做的logback.xml的设置看起来像这样。 当我启动容器时,如何在弹簧引导embedded式jar /容器中装载和加载logback.xml。 我的想法是这样的。 这将运行春季启动应用程序确定。 docker run -d –name=app1 app_image 像这样的东西是我正在寻找实现加载logback.xml docker run -d –name=app1 –volume=/home/host-path/log-back-conig-dir/:/container-app-dir/ app_image docker run -d –name=app2 –volume=/home/host-path/log-back-conig-dir/:/container-app-dir/ app_image docker run -d –name=app3 –volume=/home/host-path/log-back-conig-dir:/container-app-dir/ 更多信息 我正在使用从官方spring引导中获取的Dockerfile示例 spring.io/guides/gs/spring-boot-docker Dockerfile FROM openjdk:8-jdk-alpine VOLUME /tmp ARG JAR_FILE ADD ${JAR_FILE} app.jar ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"] logback.xml看起来像这样 <?xml version="1.0" encoding="UTF-8"?> <configuration> <springProperty scope="context" name="springAppName" source="spring.application.name"/> <include […]

春季启动应用程序工作在IntelliJ,但不是作为docker集装箱

我已经创build了一个Spring启动应用程序,它通过HTTP Post将一些Twitter的内容分析为JSON对象。 JSON对象如下所示: { "analyzedKeywords": [ { "keyword": "VW", "tweets": [ { "indicoScore": 0.8174982823, "popularity": 5659, "tweet": { "createdAt": 1512660826000, "favouriteCount": 0, "retweet": true, "retweetCount": 5, "retweetedStatus": { "createdAt": 1512660253000, "favouriteCount": 1, "retweet": false, "retweetCount": 5, "retweetedStatus": null, "tweetText": "No time for twitter drama because those VW Polo's aren't gonna strip themselves", "user": { "email": […]

spring的云无法从docker上的zuul获取服务

我有一个简单的spring云项目,它包含4个服务: configuration:8888 registry(尤里卡):8761 网关(zuul):8080 服务-1:9527 在这里input图像说明 如果在localhost中部署项目没有问题, 我可以通过没有docker的zuul成功获取service-1的api: HTTP://本地主机:8080 /服务-1 /testing 但是当我与docker部署,它抛出错误: Caused by: java.lang.RuntimeException: org.apache.http.conn.HttpHostConnectException: Connect to registry:9527 [registry/172.21.0.4] failed: Connection refused (Connection refused) 我只能用service-1的API来获取 HTTP://本地主机:9527 /testing PS:两个服务(网关,服务1)已成功注册到尤里卡 这里是我的docker – 撰写yml: version: '3' services: config: build: ./config ports: – "8888:8888" registry: build: ./registry ports: – "8761:8761" depends_on: – config environment: – SPRING_PROFILES_ACTIVE=prd gateway: build: […]

应用程序运行在Linux服务器上的本地Tomcat或Tomcat上,无法在Docker容器中的Tomcat上运行

我有一个Tomcat的问题。 当我将我的应用程序部署到本地计算机上的Tomcat时,它运行得非常完美。 当我将我的应用程序部署到远程服务器上的Tomcat时,它运行得非常完美。 但 当我将应用程序部署到在选项2中运行在同一服务器上的Docker容器中运行的Tomcat时 – 我得到了大量的错误…他们看起来像这样: [ERROR] 2017-12-13 16:14:36 Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in ServletContext resource [/WEB-INF/spring/database-context.xml]: Cannot resolve reference to bean 'entityManagerFactory' while setting bean property 'entityManagerFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/spring/database-context.xml]: Invocation of init method […]

如何测量Docker启动时间

我从一个jar文件(Spring Boot应用程序)构build一个docker镜像,但是我不能使用命令time docker run my-image来检查容器的启动时间。 由于Spring Boot的输出, docker run命令不会停止。 Dockerfile: FROM openjdk:8-jre-alpine VOLUME /tmp ADD target/myApp-0.0.1-SNAPSHOT.jar app.jar RUN sh -c 'touch /app.jar' ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "/app.jar" ] 有没有其他的方法来衡量集装箱的启动时间? 提前致谢!

docker集装箱不能够读取http链接 – 骆驼

所以我正在为Windows中的一个Camel Spring boot项目创buildDocker容器 。 在项目中,在我的camelcontext.xml的开始部分,我有以下代码 – <beans xmlns="http://www.springframework.org/schema/beans" xmlns:camel="http://camel.apache.org/schema/spring" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:security="http://www.springframework.org/schema/security" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation=" http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/beans http://www.springframework.org/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> . . // remaining part of code 现在,对于部分xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd …"docker集装箱isn无法访问.xsd文件。 另外,不知道是否相关,我有另一个单独的容器,有一个jijster应用程序,我可以在我的本地浏览器中打开该应用程序。 我也在网上几个链接中发现了DNS更改。 (通过更改,我的意思是在创build的虚拟交换机中添加8.8.8.8和8.8.4.4) 不知道为什么我无法从容器中访问文件,以及问题出在哪里。 下面是我得到的错误 – 线程“main”中的exceptionorg.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:来自类path资源[META-INF / spring / camelContext.xml]的XML文档中的第10行无效; 嵌套的exception是org.xml.sax.SAXParseException; lineNumber:10; columnNumber:44; cvc-elt.1:找不到元素“beans”的声明。 org.xml.sax.SAXParseException; […]

Docker容器通过http进行通信

我有两个应该通过http进行通信的Spring web服务。 他们都在我的机器上运行openjdk上的dcoker容器:8-al-alpine。 这是POST查询失败,“连接被拒绝”: public String createPost(int playerCount) { String uri = URI + "/create"; UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(uri) .queryParam("playerCount", playerCount); HttpEntity<?> entity = new HttpEntity<>(headers); ResponseEntity<String> response = rest.exchange( builder.build().encode().toUri(), HttpMethod.POST, entity, String.class); logger.info("Create request"); return response.getBody(); } URI是http://localhost:8090/game这里是其他服务的相应控制器: @RequestMapping( path = "create", method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) @ResponseStatus(HttpStatus.OK) public ResponseEntity<Long> create(@RequestParam("playerCount") int […]

春季领事服务健康,但在不同的东道主不能互相接触

运行领事和春云领事我有五个微服务全部注册并显示健康。 这些服务中的每一个都运行在不同的EC2实例上。 使用在领事登记的微服务的名称,我不能通过使用RestTemplate连接到其中任何一个连接 如果服务A用下面的代码调用服务B. private final static String SERVICE = "http://instance-service"; @LoadBalanced @Autowired private RestTemplate restTemplate; @GetMapping("/instances") public ResponseEntity<String> instances() { ParameterizedTypeReference<String> reference = new ParameterizedTypeReference<String>() { }; return restTemplate.exchange(SERVICE, HttpMethod.GET, null, reference); } 服务A抛出 2017-12-19 17:30:36.000 ERROR 1 — [nio-8443-exec-7] oaccC[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request […]