Skip to content

krzysbaranski/javaee-example

Repository files navigation

Java EE App

Build Status

To build app run:

mvn install

To run app in WildFly copy file target/AwesomeApp.war to $WILDFLY_HOME/standalone/deployment/

Start WildFly in Linux:

$WILDFLY_HOME/bin/standalone.sh

in Windows:

$WILDFLY_HOME/bin/standalone.bat

To add author send REST POST request to URL http://localhost:8080/AwesomeApp/rest/authors

{
  "name": "Mark",
  "surname": "Twain"
}
{
  "name": "Arthur C.",
  "surname": "Clark"
}
{
"name": "Stephen",
"surname": "Baxter"
}

For example in CURL:

curl -H "Content-Type: application/json" -X POST -d '{"name":"Mark","surname":"Twain"}' http://localhost:8080/AwesomeApp/rest/authors
curl -H "Content-Type: application/json" -X POST -d '{"name":"Arthur C.","surname":"Clark"}' http://localhost:8080/AwesomeApp/rest/authors
curl -H "Content-Type: application/json" -X POST -d '{"name":"Stephen","surname":"Baxter"}' http://localhost:8080/AwesomeApp/rest/authors

GET authors data: http://localhost:8080/AwesomeApp/rest/authors

To add book send REST POST request to URL http://localhost:8080/AwesomeApp/rest/books

{
  "title": "The Adventures of Tom Sawyer",
  "year": 1876,
  "author": [
    {
      "id": 1
    }
  ]
}
{
  "title": "Adventures of Huckleberry Finn",
  "year": 1884,
  "author": [
    {
      "id": 1
    }
  ]
}

Add book with two authors:

{
  "title": "Firstborn",
  "year": 2007,
  "author": [
    {
      "id": 2
    },
    {
      "id": 3
    }
  ]
}

For example in CURL:

curl -vv -H "Content-Type: application/json" -X POST -d '{"title":"The Adventures of Tom Sawyer","year":1876,"author":[{"id":1}]}' http://localhost:8080/AwesomeApp/rest/books
curl -vv -H "Content-Type: application/json" -X POST -d '{"title":"Adventures of Huckleberry Finn","year":1884,"author":[{"id":1}]}' http://localhost:8080/AwesomeApp/rest/books
curl -vv -H "Content-Type: application/json" -X POST -d '{"title":"Firstborn","year":2007,"author":[{"id":2},{"id":3}]}' http://localhost:8080/AwesomeApp/rest/books

About

Example Java EE application with REST API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •