经过研究,我发现spring boot在部署到云时创建了一个默认的池大小4。我正在部署到cloudfoundry,使用springboot1.3.7,并连接到mysql服务。我想增加默认池大小。我遵循这个博客中概述的步骤,但我得到下面的错误。在使用服务的自动配置时,连接到数据库没有问题,因此可以访问数据库。任何意见或建议将不胜感激!!!!!
https://spring.io/blog/2015/04/27/binding-to-data-services-with-spring-boot-in-cloud-foundry
2018-08-14T14:13:48.14-0400 [APP/PROC/WEB/0] OUT 2018-08-14 18:13:48.142 INFO 14 --- [ main] o.s.c.s.r.PooledDataSourceCreator : Found Tomcat JDBC connection pool on the classpath. Using it for DataSource connection pooling.
2018-08-14T14:13:48.42-0400 [APP/PROC/WEB/0] OUT 2018-08-14 18:13:48.422 WARN 14 --- [ main] o.a.tomcat.jdbc.pool.ConnectionPool : initialSize is larger than maxActive, setting initialSize to: 4
2018-08-14T14:13:48.42-0400 [APP/PROC/WEB/0] OUT 2018-08-14 18:13:48.422 WARN 14 --- [ main] o.a.tomcat.jdbc.pool.ConnectionPool : maxIdle is larger than maxActive, setting maxIdle to: 4
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT 2018-08-14 18:13:48.587 ERROR 14 --- [ main] o.a.tomcat.jdbc.pool.ConnectionPool : Unable to create initial connections of pool.
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_172]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_172]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_172]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_172]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at com.mysql.jdbc.Util.handleNewInstance(Util.java:404) ~[mysql-connector-java-5.1.39.jar!/:5.1.39]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:988) ~[mysql-connector-java-5.1.39.jar!/:5.1.39]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:632) ~[mysql-connector-java-5.1.39.jar!/:5.1.39]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1018) ~[mysql-connector-java-5.1.39.jar!/:5.1.39]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2253) ~[mysql-connector-java-5.1.39.jar!/:5.1.39]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2284) ~[mysql-connector-java-5.1.39.jar!/:5.1.39]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2083) ~[mysql-connector-java-5.1.39.jar!/:5.1.39]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:806) ~[mysql-connector-java-5.1.39.jar!/:5.1.39]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47) ~[mysql-connector-java-5.1.39.jar!/:5.1.39]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_172]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_172]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_172]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_172]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at com.mysql.jdbc.Util.handleNewInstance(Util.java:404) ~[mysql-connector-java-5.1.39.jar!/:5.1.39]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:410) ~[mysql-connector-java-5.1.39.jar!/:5.1.39]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:328) ~[mysql-connector-java-5.1.39.jar!/:5.1.39]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:307) ~[tomcat-jdbc-8.0.36.jar!/:na]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:200) ~[tomcat-jdbc-8.0.36.jar!/:na]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:710) [tomcat-jdbc-8.0.36.jar!/:na]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:644) [tomcat-jdbc-8.0.36.jar!/:na]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:466) [tomcat-jdbc-8.0.36.jar!/:na]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:143) [tomcat-jdbc-8.0.36.jar!/:na]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:115) [tomcat-jdbc-8.0.36.jar!/:na]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:102) [tomcat-jdbc-8.0.36.jar!/:na]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:126) [tomcat-jdbc-8.0.36.jar!/:na]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111) [spring-jdbc-4.2.7.RELEASE.jar!/:4.2.7.RELEASE]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77) [spring-jdbc-4.2.7.RELEASE.jar!/:4.2.7.RELEASE]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:338) [spring-jdbc-4.2.7.RELEASE.jar!/:4.2.7.RELEASE]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.boot.autoconfigure.jdbc.EmbeddedDatabaseConnection.isEmbedded(EmbeddedDatabaseConnection.java:139) [spring-boot-autoconfigure-1.3.7.RELEASE.jar!/:1.3.7.RELEASE]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.boot.autoconfigure.orm.jpa.JpaProperties$Hibernate.getDefaultDdlAuto(JpaProperties.java:198) [spring-boot-autoconfigure-1.3.7.RELEASE.jar!/:1.3.7.RELEASE]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.boot.autoconfigure.orm.jpa.JpaProperties$Hibernate.getOrDeduceDdlAuto(JpaProperties.java:186) [spring-boot-autoconfigure-1.3.7.RELEASE.jar!/:1.3.7.RELEASE]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.boot.autoconfigure.orm.jpa.JpaProperties$Hibernate.getAdditionalProperties(JpaProperties.java:165) [spring-boot-autoconfigure-1.3.7.RELEASE.jar!/:1.3.7.RELEASE]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.boot.autoconfigure.orm.jpa.JpaProperties$Hibernate.access$000(JpaProperties.java:126) [spring-boot-autoconfigure-1.3.7.RELEASE.jar!/:1.3.7.RELEASE]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.boot.autoconfigure.orm.jpa.JpaProperties.getHibernateProperties(JpaProperties.java:123) [spring-boot-autoconfigure-1.3.7.RELEASE.jar!/:1.3.7.RELEASE]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration.getVendorProperties(HibernateJpaAutoConfiguration.java:99) [spring-boot-autoconfigure-1.3.7.RELEASE.jar!/:1.3.7.RELEASE]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.entityManagerFactory(JpaBaseConfiguration.java:115) [spring-boot-autoconfigure-1.3.7.RELEASE.jar!/:1.3.7.RELEASE]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration$$EnhancerBySpringCGLIB$$78272a93.CGLIB$entityManagerFactory$9(<generated>) [spring-boot-autoconfigure-1.3.7.RELEASE.jar!/:1.3.7.RELEASE]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration$$EnhancerBySpringCGLIB$$78272a93$$FastClassBySpringCGLIB$$3ece12ed.invoke(<generated>) [spring-boot-autoconfigure-1.3.7.RELEASE.jar!/:1.3.7.RELEASE]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) [spring-core-4.2.7.RELEASE.jar!/:4.2.7.RELEASE]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:356) [spring-context-4.2.7.RELEASE.jar!/:4.2.7.RELEASE]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration$$EnhancerBySpringCGLIB$$78272a93.entityManagerFactory(<generated>) [spring-boot-autoconfigure-1.3.7.RELEASE.jar!/:1.3.7.RELEASE]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_172]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_172]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_172]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_172]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) [spring-beans-4.2.7.RELEASE.jar!/:4.2.7.RELEASE]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) [spring-beans-4.2.7.RELEASE.jar!/:4.2.7.RELEASE]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123) [spring-beans-4.2.7.RELEASE.jar!/:4.2.7.RELEASE]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018) [spring-beans-4.2.7.RELEASE.jar!/:4.2.7.RELEASE]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) [spring-beans-4.2.7.RELEASE.jar!/:4.2.7.RELEASE]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) [spring-beans-4.2.7.RELEASE.jar!/:4.2.7.RELEASE]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) [spring-beans-4.2.7.RELEASE.jar!/:4.2.7.RELEASE]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) [spring-beans-4.2.7.RELEASE.jar!/:4.2.7.RELEASE]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) [spring-beans-4.2.7.RELEASE.jar!/:4.2.7.RELEASE]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) [spring-beans-4.2.7.RELEASE.jar!/:4.2.7.RELEASE]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1054) [spring-context-4.2.7.RELEASE.jar!/:4.2.7.RELEASE]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:829) [spring-context-4.2.7.RELEASE.jar!/:4.2.7.RELEASE]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) [spring-context-4.2.7.RELEASE.jar!/:4.2.7.RELEASE]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) [spring-boot-1.3.7.RELEASE.jar!/:1.3.7.RELEASE]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:760) [spring-boot-1.3.7.RELEASE.jar!/:1.3.7.RELEASE]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:360) [spring-boot-1.3.7.RELEASE.jar!/:1.3.7.RELEASE]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.boot.SpringApplication.run(SpringApplication.java:306) [spring-boot-1.3.7.RELEASE.jar!/:1.3.7.RELEASE]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185) [spring-boot-1.3.7.RELEASE.jar!/:1.3.7.RELEASE]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174) [spring-boot-1.3.7.RELEASE.jar!/:1.3.7.RELEASE]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at com.emc.it.pcf.rest.api.Application.main(Application.java:25) [app/:na]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_172]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_172]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_172]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_172]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:54) [app/:na]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.boot.loader.Launcher.launch(Launcher.java:104) [app/:na]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.boot.loader.Launcher.launch(Launcher.java:61) [app/:na]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52) [app/:na]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT Caused by: java.net.SocketException: Connection reset
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at java.net.SocketInputStream.read(SocketInputStream.java:210) ~[na:1.8.0_172]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at java.net.SocketInputStream.read(SocketInputStream.java:141) ~[na:1.8.0_172]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:101) ~[mysql-connector-java-5.1.39.jar!/:5.1.39]
2018-08-14T14:13:48.58-0400 [APP/PROC/WEB/0] OUT at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:144) ~[mysql-connector-java-5.1.39.jar!/:5.1.39]
@Configuration
@Profile("cloud")
public class DatasourceCloudConfig extends AbstractCloudConfig {
//switch off build pack and spring boot autoconfiguration
@Bean
public Cloud cloud() {
return new CloudFactory().getCloud();
}
//Does not work
@Bean
@ConfigurationProperties(DataSourceProperties.PREFIX)
public DataSource dataSource() {
DataSource ds= connectionFactory().dataSource("pcf-rest-api-mysql");
return ds;
}
/*//Did not work
* @Bean
@ConfigurationProperties(DataSourceProperties.PREFIX)
public DataSource dataSource() {
return cloud().getSingletonServiceConnector(DataSource.class, null);
}*/
/*//Did not work
* @Bean
@ConfigurationProperties(prefix = DataSourceProperties.PREFIX)
public DataSource dataSource() {
return DataSourceBuilder.create().build();
}*/
}
spring.datasource.driverClassName: com.mysql.jdbc.Driver
spring.datasource.initial-size: 20
spring.datasource.testWhileIdle: true
spring.datasource.timeBetweenEvictionRunsMillis: 3600000
spring.datasource.validationQuery: SELECT 1
spring.datasource.remove-abandoned-timeout: 120
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>xxx.xxx.xxx</groupId>
<artifactId>cpe-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<groupId>xxx.xxx.xxx</groupId>
<artifactId>pcf-rest-api</artifactId>
<packaging>jar</packaging>
<name>pcf-rest-api</name>
<version>1.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<start-class>cxxx.xxx.xxx.Application</start-class>
<java.version>1.8</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-spring-service-connector</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-cloudfoundry-connector</artifactId>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.cloudfoundry</groupId>
<artifactId>cloudfoundry-client-lib</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<!-- EH Cache dependencies -->
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<exclusions>
<exclusion>
<artifactId>spring-asm</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
</dependency>
<!-- Email -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
</dependency>
<!-- Mapping -->
<dependency>
<groupId>ma.glasnost.orika</groupId>
<artifactId>orika-core</artifactId>
<version>1.4.2</version><!-- or latest version -->
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.7.0</version>
</dependency>
</dependencies>
</project>
2条答案
按热度按时间bn31dyow1#
我不能说到底发生了什么,但你可以在这里做一些事情。
如果您想使用springcloud连接器,如上面的示例所示,您需要设置poolconfig。请参阅这里的最后两个示例或以下代码段。
可以使用Spring轮廓。默认情况下,javabuildpack将为您的应用程序启用“云”概要文件,因此您可以在该概要文件中放置您只希望在cloudfoundry上运行的任何内容。然后,你可以创建一个“本地”配置文件,或者类似的东西,当你的应用程序在你的电脑上本地运行时,你可以在其中放置它的配置文件(你确实需要启用这个配置文件,它不会自动发生)。
这样,两个配置文件的内容就不会重叠,但同时您不必根据应用程序运行的环境手动交换设置。
为了它的价值,春靴
--debug
选项和/或提高日志级别org.springframework.cloud
调试将有助于调试这样的问题。你应该看到更多的细节。tez616oj2#
我准备好了。出于某种原因,springboot从本地application.yml文件中获取数据库连接url,而不是使用部署的manifest.yml中的cloudfoundry服务。当我从local application.yml中删除连接信息时,它现在可以工作了。