Giter VIP home page Giter VIP logo

task-manager-app's Introduction

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:

  • No build file.

  • Raw JDBC. I haven’t seen this since 2006. JdbcTemplate is an awesome tool that lets you only write SQL while letting Spring handle connection management. But in this day and age you can simply jump to Spring Data JPA.

  • Hand written Spring MVC RESTful endpoints. No biggie, except we now have Spring Data REST, a library that automatically exports your domain objects with a RESTful, hypermedia-drive interface.

  • XML-based Spring config and servlet context

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:

  • The front end has a habit of posting to the back end, and then fetching ALL data to re-populate the UI. It would be less taxing and more scaleable if it simply grabbed the Location header when creating a new item, GET that, and add it to the list.

  • Unfamiliar with Angular’s promises. In the step where I do a patch to update taskArchived to true, I use a JavaScript forEach statement then re-fetch all the tasks. It would be best to wait until ALL tasks are updated to do that. when.js is great resource for this.

task-manager-app's People

Contributors

gregturn avatar

Stargazers

Danislav Anufriev avatar Mohamd J Alanbaki avatar Sumeet Kumar Barua avatar Bruno Juncklaus Martins avatar Hunter xue avatar Vivek Saini avatar William Gayton avatar  avatar Enrico avatar Eduardo Flores avatar  avatar Andrew T. Finnell avatar Andrew T. Finnell avatar Onyi Cho avatar Mario Zagar avatar islam mohamed drissi avatar Armel Soro avatar Wenderson Ferreira de Souza avatar  avatar EL JEMLI avatar Pietro Bonanno avatar  avatar

Watchers

 avatar islam mohamed drissi avatar James Cloos avatar sridhar vennela avatar Juan Marques avatar Onyi Cho avatar

task-manager-app's Issues

MySQL Database AutoConfig

I wasn't able to get the production profile to auto-configure without adding a property line to app.props...

Adding the following did the trick ...

//application.properties 
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect

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.