2017-11-19 5 views
0

PCF를 통해 Pivotal 웹 서비스에 간단한 응용 프로그램을 배포하려고하지만 postgresql 또는 mysql 서비스와 같은 서비스를 바인딩하면 응용 프로그램이 중단됩니다. 응용 프로그램을 빌드하고 배포 할 수스프링 부트 서비스 바인딩을 사용하여 PCF에 응용 프로그램 배포

단계로 다음과 같습니다

MVN -DskipTests = 진정한 깨끗한

CF 푸시 -p 대상/CF-demo.jar cf102 - 데모

CF가 만든 설치

CF 결합 서비스 cf102-데모 cardb

CF-cf102 데모 다시 진행 cardb - 서비스 스파크 cleardb

응용 프로그램 원본 ->https://github.com/babarbashir/cf-demo

package com.hrsuite.cfdemo; 

import org.springframework.boot.CommandLineRunner; 
import org.springframework.boot.SpringApplication; 
import org.springframework.boot.autoconfigure.SpringBootApplication; 
import org.springframework.data.jpa.repository.JpaRepository; 
import org.springframework.stereotype.Component; 
import org.springframework.stereotype.Repository; 
import org.springframework.web.bind.annotation.GetMapping; 
import org.springframework.web.bind.annotation.RestController; 

import javax.persistence.Entity; 
import javax.persistence.GeneratedValue; 
import javax.persistence.Id; 
import java.util.stream.Stream; 

@SpringBootApplication 
public class CfDemoApplication { 

    public static void main(String[] args) { 
     SpringApplication.run(CfDemoApplication.class, args); 
    } 
} 


@RestController 
class Greetoings{ 

    @GetMapping("/hi") 
    String hi(){ 
     return "Hello, Cloud Foundry from Windows"; 
    } 
} 


@Component 
class SampleDataCLR implements CommandLineRunner{ 

    private final CarRepository carRepository; 

    public SampleDataCLR(CarRepository carRepository) { 
     this.carRepository = carRepository; 
    } 

    @Override 
    public void run(String... args) throws Exception { 
     Stream.of("Mazda", "Toyota", "Nissan") 
     .forEach(name -> carRepository.save(new Car(name))); 

     carRepository.findAll().forEach(System.out::println); 

    } 
} 



@Repository 
interface CarRepository extends JpaRepository<Car, Long>{ 

} 



@Entity 
class Car{ 

    @Id 
    @GeneratedValue 
    private Long id; 
    private String name; 

    public Car() { //for JPA 
    } 

    public Car(String name) { 
     this.name = name; 
    } 


    public Long getId() { 
     return id; 
    } 

    public void setId(Long id) { 
     this.id = id; 
    } 

    public String getName() { 
     return name; 
    } 

    public void setName(String name) { 
     this.name = name; 
    } 

    @Override 
    public String toString() { 
     return "Car{" + 
       "id=" + id + 
       ", name='" + name + '\'' + 
       '}'; 
    } 
} 

로그는 게시 한 로그는 적절한 데이터 소스를 찾을 수 있음을 나타냅니다

2017-11-22T09:24:52.733+03:00 [APP/PROC/WEB/0] [OUT] :: Spring Boot :: (v2.0.0.M6) 
2017-11-22T09:24:52.997+03:00 [APP/PROC/WEB/0] [OUT] 2017-11-22 06:24:52.988 INFO 13 --- [ main] pertySourceApplicationContextInitializer : Adding 'cloud' PropertySource to ApplicationContext 
2017-11-22T09:24:56.715+03:00 [APP/PROC/WEB/0] [OUT] 2017-11-22 06:24:56.408 INFO 13 --- [ main] urceCloudServiceBeanFactoryPostProcessor : Auto-reconfiguring beans of type javax.sql.DataSource 
2017-11-22T09:24:56.728+03:00 [APP/PROC/WEB/0] [OUT] 2017-11-22 06:24:56.723 INFO 13 --- [ main] urceCloudServiceBeanFactoryPostProcessor : No matching service found. Skipping auto-reconfiguration. 
2017-11-22T09:24:57.090+03:00 [APP/PROC/WEB/0] [OUT] 2017-11-22 06:24:57.090 INFO 13 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$8755c8ae] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 
2017-11-22T09:24:59.342+03:00 [APP/PROC/WEB/0] [OUT] 2017-11-22 06:24:59.342 WARN 13 --- [ost-startStop-1] aWebConfiguration$JpaWebMvcConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning 
2017-11-22T09:24:59.411+03:00 [APP/PROC/WEB/0] [OUT] 2017-11-22 06:24:59.410 ERROR 13 --- [ost-startStop-1] o.s.b.web.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'webMetricsFilter' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsConfiguration.class]: Unsatisfied dependency expressed through method 'webMetricsFilter' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcHandlerMappingIntrospector' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping]: Factory method 'requestMappingHandlerMapping' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'openEntityManagerInViewInterceptor' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/JpaBaseConfiguration$JpaWebConfiguration$JpaWebMvcConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (the profiles "cloud" are currently active). 
2017-11-22T09:24:59.465+03:00 [APP/PROC/WEB/0] [OUT] 2017-11-22 06:24:59.465 WARN 13 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat 
2017-11-22T09:24:59.491+03:00 [APP/PROC/WEB/0] [OUT] 2017-11-22 06:24:59.491 INFO 13 --- [ main] utoConfigurationReportLoggingInitializer : 
2017-11-22T09:24:59.491+03:00 [APP/PROC/WEB/0] [OUT] Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. 
2017-11-22T09:24:59.495+03:00 [APP/PROC/WEB/0] [OUT] 2017-11-22 06:24:59.494 ERROR 13 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : 
2017-11-22T09:24:59.495+03:00 [APP/PROC/WEB/0] [OUT] *************************** 
2017-11-22T09:24:59.495+03:00 [APP/PROC/WEB/0] [OUT] APPLICATION FAILED TO START 
2017-11-22T09:24:59.495+03:00 [APP/PROC/WEB/0] [OUT] Description: 
2017-11-22T09:24:59.495+03:00 [APP/PROC/WEB/0] [OUT] Cannot determine embedded database driver class for database type NONE 
2017-11-22T09:24:59.495+03:00 [APP/PROC/WEB/0] [OUT] Action: 
2017-11-22T09:24:59.495+03:00 [APP/PROC/WEB/0] [OUT] If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (the profiles "cloud" are currently active). 
2017-11-22T09:24:59.550+03:00 [APP/PROC/WEB/0] [OUT] Exit status 1 
2017-11-22T09:24:59.556+03:00 [CELL/SSHD/0] [OUT] Exit status 0 
2017-11-22T09:24:59.583+03:00 [API/22] [OUT] Process has crashed with type: "web" 
2017-11-22T09:24:59.594+03:00 [API/22] [OUT] App instance exited with guid 7d2b8a4c-5a2c-46af-a0a7-da376db94893 payload: {"instance"=>"458f5872-9dea-4690-4485-1115", "index"=>0, "reason"=>"CRASHED", "exit_description"=>"APP/PROC/WEB: Exited with status 1", "crash_count"=>1, "crash_timestamp"=>1511331899564724498, "version"=>"1c46af47-5605-4936-9846-61bdf9f50bdb"} 
2017-11-22T09:24:59.596+03:00 [CELL/0] [OUT] Stopping instance 458f5872-9dea-4690-4485-1115 
2017-11-22T09:24:59.596+03:00 [CELL/0] [OUT] Destroying container 
2017-11-22T09:24:59.935+03:00 [CELL/0] [OUT] Successfully destroyed container 
+1

cf logs cf102-demo -recent의 출력은 무엇입니까? –

+0

감사합니다. Josh, 참조 용으로 로그를 추가했습니다. – BABAR

답변

0

다음과 같습니다.

<dependency> 
    <groupId>org.springframework.cloud</groupId> 
    <artifactId>spring-cloud-cloudfoundry-connector</artifactId> 
    <version>2.0.1.RELEASE</version> 
</dependency> 

이 커넥터는 VCAP_SERVICES 환경 변수를 검사하고 DataSource 콩을 만들기 위해 봄 런타임에서 사용할 수있는 ServiceInfo 객체를 생성합니다 : 코드보고 후, 나는 당신의 POM에 다음 다시 시도 추가 제안 .