Giter Site home page Giter Site logo

reljicd / spring-boot-shopping-cart Goto Github PK

View Code? Open in Web Editor NEW
186.0 20.0 155.0 110 KB

Simple shopping cart web app made using Spring Boot + Thymeleaf

License: GNU General Public License v3.0

Shell 13.34% Batchfile 9.10% Java 52.62% CSS 0.64% HTML 24.30%
spring-boot spring spring-mvc spring-data-jpa spring-data-rest thymeleaf java spring-security h2-database h2

spring-boot-shopping-cart's Introduction

Spring Boot Shopping Cart Web App

About

This is a demo project for practicing Spring + Thymeleaf. The idea was to build some basic shopping cart web app.

It was made using Spring Boot, Spring Security, Thymeleaf, Spring Data JPA, Spring Data REST and Docker. Database is in memory H2.

There is a login and registration functionality included.

Users can shop for products. Each user has his own shopping cart (session functionality). Checkout is transactional.

Configuration

Configuration Files

Folder src/resources/ contains config files for shopping-cart Spring Boot application.

  • src/resources/application.properties - main configuration file. Here it is possible to change admin username/password, as well as change the port number.

How to run

There are several ways to run the application. You can run it from the command line with included Maven Wrapper, Maven or Docker.

Once the app starts, go to the web browser and visit http://localhost:8070/home

Admin username: admin

Admin password: admin

User username: user

User password: password

Maven Wrapper

Using the Maven Plugin

Go to the root folder of the application and type:

$ chmod +x scripts/mvnw
$ scripts/mvnw spring-boot:run

Using Executable Jar

Or you can build the JAR file with

$ scripts/mvnw clean package

Then you can run the JAR file:

$ java -jar target/shopping-cart-0.0.1-SNAPSHOT.jar

Maven

Open a terminal and run the following commands to ensure that you have valid versions of Java and Maven installed:

$ java -version
java version "1.8.0_102"
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)
$ mvn -v
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T16:41:47+00:00)
Maven home: /usr/local/Cellar/maven/3.3.9/libexec
Java version: 1.8.0_102, vendor: Oracle Corporation

Using the Maven Plugin

The Spring Boot Maven plugin includes a run goal that can be used to quickly compile and run your application. Applications run in an exploded form, as they do in your IDE. The following example shows a typical Maven command to run a Spring Boot application:

$ mvn spring-boot:run

Using Executable Jar

To create an executable jar run:

$ mvn clean package

To run that application, use the java -jar command, as follows:

$ java -jar target/shopping-cart-0.0.1-SNAPSHOT.jar

To exit the application, press ctrl-c.

Docker

It is possible to run shopping-cart using Docker:

Build Docker image:

$ mvn clean package
$ docker build -t shopping-cart:dev -f docker/Dockerfile .

Run Docker container:

$ docker run --rm -i -p 8070:8070 \
      --name shopping-cart \
      shopping-cart:dev
Helper script

It is possible to run all of the above with helper script:

$ chmod +x scripts/run_docker.sh
$ scripts/run_docker.sh

Docker

Folder docker contains:

  • docker/shopping-cart/Dockerfile - Docker build file for executing shopping-cart Docker image. Instructions to build artifacts, copy build artifacts to docker image and then run app on proper port with proper configuration file.

Util Scripts

  • scripts/run_docker.sh.sh - util script for running shopping-cart Docker container using docker/Dockerfile

Tests

Tests can be run by executing following command from the root of the project:

$ mvn test

Helper Tools

HAL REST Browser

Go to the web browser and visit http://localhost:8070/

You will need to be authenticated to be able to see this page.

H2 Database web interface

Go to the web browser and visit http://localhost:8070/h2-console

In field JDBC URL put

jdbc:h2:mem:shopping_cart_db

In /src/main/resources/application.properties file it is possible to change both web interface url path, as well as the datasource url.

spring-boot-shopping-cart's People

Contributors

reljicd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spring-boot-shopping-cart's Issues

mvn compile fails

details-
OS: windows
Java version: open jdk 11
maven version: 3.6.3

Checkout issue

Is there any issue with checkout module? When I checkout I dont see all the products and final price.

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.