草庐IT

viewer_two_clouds

全部标签

java - Tomcat : HikariCP issue when deploying two applications with DB connection

我试图在同一个tomcat7实例上部署两个WAR文件(app1.war和app2.war)。我收到此错误:UnabletoregisterMBean[HikariDataSource(HikariPool-0)]withkey'dataSource';nestedexceptionisjavax.management.InstanceAlreadyExistsException:com.zaxxer.hikari:name=dataSource,type=HikariDataSource如果我在tomcat上只部署了一个应用程序,我就不会出现这个错误。有办法解决这个问题吗?

java - 使用spring cloud更改eureka服务器的默认端口

我得到了spring-boot应用程序、一个eureka服务器和一个eureka客户端。这是我的服务器配置server:port:8761spring:application:name:eureka-server这是我的服务器代码packagefr.maif.eurekaserver;importorg.springframework.boot.SpringApplication;importorg.springframework.boot.autoconfigure.SpringBootApplication;importorg.springframework.cloud.netfl

java - 将小数点 1 到 10 替换为名称 ("one", "two"..)

我试图获取一个字符串,然后返回一个字符串,其中数字1到10替换为这些数字的单词。例如:Iwon7ofthe10gamesandreceived30dollars.应该变成:Iwonsevenofthetengamesandreceived30dollars.所以我这样做了:importorg.apache.commons.lang3.StringUtils;String[]numbers=newString[]{"1","2","3","4","5","6","7","8","9","10"};String[]words=newString[]{"one","two","three",

java - spring cloud feign hystrix 回退不起作用

与springboot版本1.3.8.RELEASE和云版本“Brixton.SR”相同的代码工作正常。但是“1.5.2.RELEASE”和“Dalston.RC1”不起作用。异常HTTP状态500-请求处理失败;嵌套异常是java.lang.RuntimeException:com.netflix.client.ClientException:Loadbalancerdoesnothaveavailableserverforclient:math-service 最佳答案 好的,您可以将以下内容添加到您的application.p

java util logging.properties : How to log to two different files

我在tomcat的WEB-INF/classes目录中放置了一个logging.properties我想登录到两个不同的文件。例如:org.pkg1转到一个文件,org.pkg2转到另一个文件。我可以配置一个文件,但不能配置两个。这可能吗? 最佳答案 我终于明白了。在tomcat中,他们扩展了javautil日志记录(“JULI”)以启用此功能。这是我放在WEB-INF目录中的一个logging.properties文件,它最终完成了我想要的……:handlers=1console.java.util.logging.Console

Java 日历 : Getting Difference Between Two Dates/Times - Off by One

我看过很多关于这个主题的问题和答案,但没有一个能解决我的特定问题。我扩展了javaCalendar类(标准——没有第三方库),并且需要找出两个任意日期之间的天差异。方法:将两个日期的时间都改为午夜。将日期转换为毫秒。找出两个日期之间的差异。将结果除以一天中的毫秒数(24*60*60*1000)。结果应该是天数之差。有时是,有时不是。即使是同一天的考试也可能相差一个。怎么回事? 最佳答案 JodaTime图书馆对此类问题有很好的支持:LocalDated1=newLocalDate(calendar1.getTimeInMillis(

java - 无法使用 Google App Engine (GAE) 连接到 Google Cloud Messaging (GCM) 服务器

我正在尝试为我的应用程序设置谷歌云消息传递,并且我正在为我的服务器使用GoogleAppEngine。我有我的APIkey,但我似乎无法连接到谷歌云消息服务器。这是我的代码。HttpClientclient=newDefaultHttpClient();HttpPostpost=newHttpPost("https://android.googleapis.com/gcm/send");try{ListnameValuePairs=newArrayList(2);nameValuePairs.add(newBasicNameValuePair("registration_id",reg

java - 为什么 Google Cloud API 会尝试以最终用户身份进行连接?

我正在尝试使用GoogleCloudTranslateAPI。我从服务帐户生成了一个JSON文件,并将GOOGLE_APPLICATION_CREDENTIALS设置为保存JSON文件的位置。然后我在这样的程序中使用它:importcom.google.cloud.translate.*;...Translatetranslate=TranslateOptions.getDefaultInstance().getService();Translationtranslation=translate.translate(message);但是我得到以下错误com.google.cloud.

Java 8 : Merging two Lists containing objects by key

我有两个列表:Listservers1=newArrayList();Servers1=newServer("MyServer");s1.setAttribute1("Attribute1");servers1.add(s1);Listservers2=newArrayList();Servers2=newServer("MyServer");s2.setAttribute2("Attribute2");servers2.add(s2);servers1包含具有name和attribute1(但没有attribute2)的服务器。servers2包含具有name和attribute2(

java - spring-cloud和ribbon能否实现基于DNS的负载均衡?

Cloudfoundry计划添加对映射到多个IP(每个应用程序容器实例一个)的DNSA记录的支持,请参阅docs-proposal.不知道spring-clouddiscovery加上ribbon能不能支持基于DNS的客户端负载均衡。spring-cloudDiscoveryClient好像不做DNS解析,它管理hostnamesribbon负载平衡库通过ListOfServers支持FQDN列表属性(property)。但我无法找到与指定服务器的DNS查找相关的文档:即如果DNSA/AAA记录(从ListOfServers获取)返回多个IP地址,Ribbon是否会在IP地址之间进行负