GithubHelp home page GithubHelp logo

beer-api's Introduction

Spring-Boot and Camel XML QuickStart

This example demonstrates a Spring Boot example running a Camel REST route connecting to a PostgreSQL database.

The application utilizes the Spring @ImportResource annotation to load a Camel Context definition via a camel-context.xml file on the classpath.

Building

The example can be built with

mvn clean install

Running the example in OpenShift

It is assumed that:

Login as developer

~/Projects/git/beer-api on master*

$ oc login -u developer -p developer
Login successful.

You don't have any projects. You can try to create a new project, by running

oc new-project <projectname>    

Create project beer

$ oc new-project beer
Now using project "beer" on server "https://192.168.64.29:8443".

You can add applications to this project with the 'new-app' command. For example, try:

    oc new-app centos/ruby-22-centos7~https://github.com/openshift/ruby-ex.git

to build a new example application in Ruby.

Setup PostgreSQL database

  • Go to the OpenShift Web Console

  • Select the beer project previously created

  • Add a PostgreSQL database with the following settings:

    • Database service name: postgresql
    • PostgreSQL Connection Username: beeruser
    • PostgreSQL Connection Password: beerpw
    • PostgreSQL Database Name: beerdb

Grep the running postgresql pod with:

$ oc get pods | grep postgresql

postgresql-1-qjq75   1/1       Running   0          1m
  • Copy data files into the pod

To create the tables and load data into the table use the following steps:

$ oc cp postgres/breweries.csv postgresql-1-qjq75:/tmp/

$ oc cp postgres/beers.csv postgresql-1-qjq75:/tmp/

$ oc cp postgres/*.sql postgresql-1-qjq75:/tmp/
 
$ oc rsh postgresql-1-qjq75
sh-4.2$ ls /tmp

beers.csv  breweries.csv  ks-script-hE5IPf  openbeer-psql.sql  yum.log

sh-4.2$ psql -d beerdb -f /tmp/openbeer-psql.sql -W
Password: postgres
CREATE TABLE
COPY 1414
CREATE TABLE
COPY 5901

sh-4.2$ psql -d beerdb
beerdb=# grant all privileges on all tables in schema public to beeruser;
GRANT

beerdb=# \q

sh-4.2$ exit

SpringBoot Application

The example can be built and run on OpenShift using a single goal:

mvn -s settings.xml fabric8:deploy

To list all the running pods:

oc get pods

Then find the name of the pod that runs this quickstart, and output the logs from the running pods with:

oc logs <name of pod>

You can also use the OpenShift web console to manage the running pods, and view logs and much more.

Using the beer API

You can use the following URLs (replace api-route with the correct URL as mentioned in the OpenShift Web Console) to test out the API we just implemented and is running on Red Hat OpenShift and waiting to be consumed.

beer-api's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.