Skip to content

Instantly share code, notes, and snippets.

@yogendra
Last active May 2, 2019 07:32
Show Gist options
  • Save yogendra/5954a82273b88845c43693d01d106626 to your computer and use it in GitHub Desktop.
Save yogendra/5954a82273b88845c43693d01d106626 to your computer and use it in GitHub Desktop.
Spring Boot to PCF
spring.application.name=My First Spring Boot Application
cf api --skip-ssl-validation api.sys.aleppo.cf-app.com
cf login
cf api api.run.pivotal.io
cf login
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
package com.example.springboottopcf;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Entity
@NoArgsConstructor
@AllArgsConstructor
public class Employee {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String name;
}
spring.jpa.hibernate.ddl-auto=none
spring.datasource.initialization-mode=always
package com.example.springboottopcf;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.rest.webmvc.RepositoryRestController;
@RepositoryRestController
public interface EmployeeRepository extends JpaRepository<Employee, Long> {
}
insert into employee (name) values ('pas');
insert into employee (name) values ('lucia');
insert into employee (name) values ('lucas');
insert into employee (name) values ('siena');
DROP TABLE IF EXISTS employee;
CREATE TABLE employee (
id bigint NOT NULL AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(30)
)
AUTO_INCREMENT=1;
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
management.endpoint.health.enabled=true
management.endpoint.health.show-details=always
management.endpoints.enabled-by-default=true
management.endpoints.web.exposure.include=*
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
---
applications:
- name: employee-api
memory: 1G
instances: 1
random-route: true
path: ./target/demo-0.0.1-SNAPSHOT.jar
#!/bin/bash
while true do
echo "Press [CTRL+C] to stop.."
http https://$1/employees
sleep 2
done
@echo off
:loop
echo "Press [CTRL+C] to stop.."
http https://%1/employees
goto loop
:exitloop
<project>
<!---....--->
<properties>
<!---...--->
<spring-cloud.version>Greenwich.RELEASE</spring-cloud.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!---...--->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>
<!---...--->
</dependencies>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment