Starter project for training classes. This is a partial implementation of a sample application. It constitutes a portion of the material used in the class. The class facilitator will provide further information about what to do with it. The project is not intended for self-study, although the code may contain some useful examples.
This version of Bookstore is based on the following technologies:
- Java 8
- JUnit 5
- Spring Boot
- JPA talking to MySQL 5.7
- Cucumber (Ruby) for API testing
Follow the instructions to install MySQL for your platform. MySQL site
git clone https://github.com/neopragma/java-bookstore.git
This creates a database named bookstore and a user named bookstore on localhost with a password of bookstore. This is the application's userid for MySQL.
mysql -u root -p < create_bookstore_database.sql
Install dependencies and run unit tests.
mvn install
mvn test
Start the server on localhost.
If using Maven:
mvn spring-boot:run
If using Gradle:
gradle bootRun
In a browser, navigate to http://localhost:8080. Alternatively, if you have curl and jq installed, you can run:
curl -s http://localhost:8080 | jq .
If the server returns something like the following, then you're doing OK so far.
{
"description": "Bookstore Service",
"version": "v1",
"requests": [
{
"http-verb": "get",
"uri": "/",
"description": "returns api help"
},
{
"http-verb": "get",
"uri": "/v1/books",
"description": "returns list of all books"
},
{
"http-verb": "post",
"uri": "/v1/book",
"description": "add a book"
},
{
"http-verb": "get",
"uri": "/v1/authors",
"description": "returns list of all authors"
},
{
"http-verb": "post",
"uri": "/v1/author",
"description": "add an author"
},
{
"http-verb": "post",
"uri": "/v1/book/{bookId}/author/{authorId}",
"description": "associate an author with a book"
}
]
}
Postman is handy for playing with the API interactively. Postman site
If you choose to use Postman, you will find some saved API calls in Backup.postman_dump.json. That file can be imported into Postman.
This is not a UI project. The sample application is a RESTful service. A separate project can be used to explore/test/demonstrate a web-based UI for the Bookstore service. The repo for that project is here: Bookstore UI.