gregturn / task-manager-app

After reading http://www.programming-free.com/2014/07/crud-springmvc-restful-webservices-angularjs.html, I rewrite the code using Spring Data REST to simplify
22 stars 12 forks source link

This code is another demo of how Spring Data REST can massively simplify code.

The original project had a simple domain object. Then it created a customer Spring MVC controller to create RESTful CRUD ops. Backing the controller was a service layer that used raw JDBC code to perform various CRUD ops to a persistent data store.

Issues:

I basically threw out the controller, the DAO, and the connection creation library. I edited the domain POJO so that field names matched the getters/setters. (Spring Data couldn't handle such a deviation). No more need for a connection creation library. I then created a TaskRepository interface and added a few custom finders. From there, I was able to focus all my effort on fixing the Angular front end to talk to the right endpoints. Even though I didn't know a thing about Angular, I was able to fix things up and get the app working again.

I create a maven build file, so it's quick and easy to run.

== To run in "dev" mode

This runs things in a local "dev" mode by using the in-memory H2 database.

From the command-line:


$ mvn clean spring-boot:run ...

Build a runnable JAR

$ mvn clean package $ java -jar target/spring-and-angular-0.0.1-SNAPSHOT.jar ...

Or from your IDE, run Application.main.

From there, navigate to http://localhost:8080/home.

== To run in "production" mode

NOTE: This runs things in a local "dev" mode by using the in-memory H2 database.

From the command line:

$ SPRING_PROFILES_ACTIVE=production mvn spring-boot:run

You can also build and run as an executable JAR file:


$ mvn package $ java -jar -Dspring.profiles.active=production target/spring-and-angular-0.0.1-SNAPSHOT.jar

WARNING: -Dspring.profiles.active=production does NOT work when running mvn spring-boot:run.

New Issues: