Skip to content

Simple Demo for Java, and make it runing on SAP BTP Cloud foundry enviroment

License

Notifications You must be signed in to change notification settings

seyaFly/SAPBTP_JAVA_SIMPLE

Repository files navigation

English | 中文

This Repository is the BTP Simple Demo Application for Java Applicaiton. we can use this demo to familiary with the SAP BTP Java Development Lifecycle.

After that , you can directly user the template for further development or build another applicaitons with you own development

Table Of Content

Preparation

BTP Account

Use this link to apply and setup the BTP trial or enterpise enviroment

Tools

Java

Install and setup the Java JDK1.8 or higher

Maven

Install and setup Maven 3.5.0 or higher

IDE

we can use the Eclipse, Idea , Theia or VSC as you favourite development IDE, or other IDE you want.

CF Command line

Dowanload and Configration : Download and Install the Cloud Foundry Command Line Interface

Direct Download link: https://github.com/cloudfoundry/cli#downloads

Development

Steps :

  1. create Spring Boot application via SpringBoot Intializer. In this Simple Application , here are the information we configured:

        groupId : onem.seya 
        artifactId: javademo
    
  2. Add Dependency, Spirng Web + Rest Repository

    Denpendcy

  3. create controllerfolder and add the class HelloWorldController

    JavaPackage

  4. Add the sample code and save it

     @RestController
     @RequestMapping(HelloWorldController.PATH)
     public class HelloWorldController {
         public static final String PATH = "/api";
    
         @GetMapping(value = "/welcome")
         public String printHelloWord() {
             String welcomeMessage = "Hello, this is BTP SAP JAVA Simple Demo";
             return welcomeMessage;
         }
     }

Build

build java application package with the command line mvn package

Test(local)

Run java application package with command line Java -jar XXXX.jar

Test it with the link : http://localhost:8080/api/welcome

and get the response.

Hello, this is BTP SAP JAVA Simple Demo

After that , this whole java applciation is working fine

Deployment

Deploy for BTP:

  1. set cloud foundry endpoint command :

    cf api {EndpointURL}

    EndpointURL you can find in your subaccount : APIEndPoint

  2. login to your BTP endpoint with your btp user and password command :

    cf login

  3. add manifest.yml for CF BTP development

  4. configure the route and java buildpacks

here we suggest use bellow format as recomendation :

  {subdomain}-{appname}.{cfappdoman}

subdomain:

subdomain

appname: defined by yourself

cfappsdomain: user the command cf domains to get the domain url

cfappdomain

Example:

   ---
   applications:
   - name: demo
   memory: 400M
   path: target/btp_JavaApplicatin.jar
   instances: 1
   buildpacks: 
      - sap_java_buildpack
   env:
      TARGET_RUNTIME: tomee7
   routes: 
      - route: 91ccc175trial-demo.cfapps.ap21.hana.ondemand.com 
  1. Deploy your jar packges to your BTP Subaccount

    command :

    cf push

Test(BTP subaccount)

  1. Navigte to your space

space

  1. Go you applcation

space_application

  1. Get applicaiton URL

applicationOverview

  1. Test it with the URL

    {applicaitonURL}/api/welcome
    

    After get the below response, then your application is runtime fine

    Hello, this is BTP SAP JAVA Simple Demo

Reference

SpringBoot Rest Service Guide : SpringBoot Rest Service Guide

SAP BTP JAVA Development: Developing Java in the Cloud Foundry Environment

About

Simple Demo for Java, and make it runing on SAP BTP Cloud foundry enviroment

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages