This project demonstrates Spring Data JPA, Spring Data Solr, Spring Web MVC, Spring Security and Thymeleaf. It accompanies blog posts at http://nixmash.com which are listed below in their accompanying implementation version. See the Installation section below on how to quickly configure application settings to run NixMash Spring.
A working demo of the site is online at http://nixmashspring.daveburkevt.com.
##Implemented##
Implementations listed in the Release History below are found in their corresponding branch, v0.0.1, v0.0.2, etc. Newer branches may not contain features found in prior versions.
##Release History##
- v0.2.8 -- Spring Social : Integrated Facebook and Twitter Authentication with existing site Spring Security Accounts
- v0.2.7 -- Solr MVC : Web Solr Search, Autocomplete, Web Solr Facet, Solr Location Searching with Google Maps, Highlighting
- v0.2.6 -- Solr Query Samplings : Solr Annotated, Criteria, Method Name Queries, Facet Queries
- v0.2.5 -- Spring Boot 1.3 : Update all libraries to support v1.3
- v0.2.4 -- Multiple Solr Repository Configurations : Four different examples of configuring Solr Repositories
- v0.2.3 -- Initial Solr Release : Embedded and HTTP Solr Server profiles, SimpleSolrRepository CRUD Queries, Spring Annotation Solr Context Configuration
- v0.2.2 -- Eclipse-Friendly NixMash Spring : Project Gradle build and configuration updated to support Eclipse IDE
- v0.2.1 -- Spring MVC and JavaScript Samplings : Bootstrap Dialog Box supporting Spring User Authentication, Spring MVC JSON-Populated Multiselect plugin, SpringLoaded for Hot Reload development
- v0.2.0 -- Spring Data JPA Auditing : Spring JPA Auditing with ZonedDateTime and MySQL support
- v0.1.9 -- More Child Object Handling in MVC and Thymeleaf : Hobbies added to Contact Forms, Custom Data Validation, CommandLineRunner example, Form JUnit Tests
- v0.1.8 -- Child Object Processing (Phones), MVC Method Level Security : PreAuthorize Annotation and Sp-EL MVC Method Security, Thymeleaf Forms
- v0.1.7 -- Full MySQL Support, WAR Deployment : Application deployed as WAR with deployment script, @ControllerAdvice
- v0.1.6 -- Initial Release w/ Spring Security : Spring Security with User Login and Registration, Role-based Contact Details viewing, External Properties file configuration
- v0.1.5 -- Contact Add/Update Form, Dandelion Asset Bundling : Dandelion Asset Bundling, Custom Favicon, Custom Exception Handling and all supporting Tests
- v0.1.4 -- Contact Display, List and Search : jQuery, Bootstrap and Bootswatch Webjars with Spring, Contact web display with Thymeleaf
- v0.1.3 -- Initial release w/ Thymeleaf
- v0.1.2 -- Multi-Module with JPA and MVC Modules : MVC Module added to project, initial HomeController and ContactControllers, Pretty Formatted JSON with Jayway
- v0.1.1 -- @ManyToMany Hobbies added to Contact Model
- v0.1.0 -- @OneToMany Contact Phones added to Contact Model
- v0.0.9 -- Lazy Loading examples
- v0.0.8 -- Multi-database configuration w/ H2Console and MySQL
- v0.0.7 -- Multi-profile configuration : PROD and DEV Spring Profiles
- v0.0.6 -- GUI Generated Entities and Diagram Examples : IntelliJ IDE Persistence Tool Demos
- v0.0.5 -- Hibernate and JPA Module structure
- v0.0.4 -- Initial Release with JPA
- v0.0.3 -- DAO Implementation
- v0.0.2 -- Using Spring Properties : Using Property Files, @Value and @Autowired Environment properties, @ImportResource of app-context.xml demo
- v0.0.1 -- Base Configuration in Spring and Hibernate : Spring Annotation Configuration, Lazy Fetching, Named Queries, Logging, Gradle Build Configuration
##v0.2.8 -- Spring Social (In Progress)##
- Post: Spring Boot Social Showcase Starting Points
- Post: Facebook Email Access in Spring Boot Social Showcase
##v0.2.7 -- Solr MVC##
- Replaced application-dev.properties/application-prod.properties logic with External Properties file
solr.properties
- Configured for local and public Solr Server Url of http://solr/nixmashspring or a public url
- Updated Solr Index Installation "refreshSolr.sh" script to support new Url logic
- Updated Solr Server to 4.10.4
- Web display of Solr Facets
- Web Solr Search
- Solr Highlighting
- Solr Spatial Searching and Location Data handling
- Display Map with Google Map Javascript API, Thymeleaf and Solr Product Location data
- Post: Pagination with Spring MVC, Solr, Thymeleaf and Bootstrap
- Post: Testing for Malformed Solr Query Strings
- Post: Solr Faceted Search Example in Spring and Thymeleaf
- Post: Solr Search Term Autocomplete with Spring MVC
- Post: Retrieving Location Data with Spring Solr
- Post: Location Queries with Spring Data Solr
- Post: Thymeleaf Conditions, Comma Control and Glyphicons as List Styles
- Post: Using Google Maps API with Thymeleaf and Spring
- Post: A Google Multi-Marker Map Example with Solr, Spring MVC and Thymeleaf
- Post: Highlighted Search Results with Spring Solr
##v0.2.6 -- Solr Query Samplings##
- Tests for CRUD and Custom Solr Queries
- Console demonstrations of Named Method Queries, Java Criteria API, Annotated Queries, Named Queries and Solr Facets
- Post: Simple CRUD Examples With Spring Data Solr
- Post: A Spring Solr Criteria API Query Example
- Post: Spring Solr Named and Annotated Query Examples
- Post: A Named Method Query With A Solr Twist
- Post: Changing the Size of Solr Facet Pages
- Post: Spring Solr Facet Query Examples
##v0.2.5 -- Spring Boot 1.3##
- Spring-Boot-1.3.0.RELEASE
##v0.2.4 -- Multiple Solr Repository Configurations##
- Four different examples of configuring Solr Repositories
-
- Simple @NoRepositoryBean, 2) Derived @NoRepositoryBean, 3) Custom w/ @Repository, 4) SolrFactoryBean Shared Model Repository
- Post: Four Spring Solr Repository Configurations
##v0.2.3 -- Initial Solr Release##
- New Solr Project based on Solr TechProducts Demo Collection in v5.3.2
- Embedded and HTTP Solr Server configuration (Profiles "dev" and "prod" respectively)
- Solr Data files and script for populating, refreshing Http and Embedded Solr indexes
- Method Name and SimpleSolrRepository base CRUD Queries
- Java Annotation Solr Context Configuration
- Post: On Embedded Solr Paths and Http Solr Server Urls
- Post: Profile-Specific Application.Properties in Spring
- Post: Solr Http and Embedded Data Refresh for Development
- Post: Spring Solr Minimum Daily Configuration Requirements
##v0.2.2 -- Eclipse-Friendly NixMash Spring##
- Modified Gradle build.gradle files to eliminate Eclipse Build errors
- Added JDK JAVA_HOME properties to root Gradle .properties files
- Updated Gradle Wrapper to v2.7
- Post: Prepping Eclipse Mars for Spring and Gradle
- Post: Loading a Multi-Project Gradle Application in Eclipse
##v0.2.1 -- Spring MVC and JavaScript Samplings##
- Bootstrap Dialog Box with requirement to be logged-in to view
- JQuery Bootstrap Multiselect Plugin with Spring MVC JSON-populated Options and postback
- SpringLoaded to Hot Reload Java Class updates w/o app restart
- Post: BootRun Hot Deploy with Spring Loaded in IntelliJ
- Post: JavaScript, Thymeleaf, Spring MVC and a Dialog Box
- Post: Spring MVC, JSON, CSRF, and a Bootstrap Multiselect Plugin
- Post: Populate Bootstrap Multiselect Options with JSON and Spring MVC
##v0.2.0 -- Spring Data JPA Auditing##
- Spring Data JPA Auditing
- Post: Spring JPA Auditing with ZonedDateTime and MySQL
- Post: A Spring War Deployment Bash Script
##v0.1.9 -- More Child Object Handling in MVC and Thymeleaf##
- Hobbies added to Contact Update Form w/ Custom Data Validation
- Demo of Spring Boot CommandLineRunner
- Contact Form tests added
- Post: Using Spring Boot CommandLineRunner
- Post: Testing Custom Exception Handling Classes in Spring MVC
- Post: Handling Null Radio Button Data in Thymeleaf and Spring MVC
##v0.1.8 -- Child Object Processing (Phones), MVC Method Level Security##
- Add, Update, Remove Contact Phones added to Contact Update form
- User Profile Page with @PreAuthorize to enforce owner-only plus administrator profile view
- Post: Spring MVC Method Security with @PreAuthorize and Sp-EL
- Post: Consistent Fonts with Bootstrap Glyphicon and Thymeleaf
- Post: Object Child Lists in Thymeleaf Forms and Spring MVC
##v0.1.7 -- Full MySQL Support, WAR Deployment##
- MySQL Spring Security Support (mysql.setup file now located in /install folder)
- Deployed as a WAR at http://nixmashspring.daveburkevt.com
- @ControllerAdvice firing issue with AddViewControllers() fix
- User Login and Registration Tests
- Post: Why Your @ControllerAdvice May Not Be Firing
- Post: Deploying Your Spring Boot WAR Application
- Post: Adding MySQL Spring Security to Existing H2 App
##v0.1.6 -- Initial Release w/ Spring Security##
- Spring Security with Login and User Registration. Supports Multiple Role Assignment with USERS, USER`AUTHORITIES and AUTHORITIES table storage
- H2 Console support at http://site/console. USER Role Access Denied to Console
- User must be authenticated to view Contact Details and Search pages
- External Properties for configuring options based on site public status (is demo site) To Configure Location of Properties File: Set in Jpa/ApplicationSettings.class annotation
- Create Contact Update/Create Submit restricted to ADMIN Role
- Tests for New User Registration and Form Validation
- Note: v0.1.6 supports H2Database only. MySql support to be added.
- Post: Using the H2 Console in Spring and IntelliJ
- Post: Beware Your Spring Security Principal’s Authorities Format
- Post: Spring Security in NixMash Spring App: The Parts You Can See
- Post: Welcome, User! in Thymeleaf and Spring
- Post: Enabling Submit on User Role in Thymeleaf and Spring
- Post: The Old InstanceAlreadyExistsException JUnit Trick
- Post: External Properties File for Spring Web Site Configuration
- Post: Saving Multiple Authorities to Database on New User in Spring
- Post: User Registration Validation in Spring
##v0.1.5 -- Contact Add/Update Form, Dandelion Asset Bundling##
- Multi-use Contact Add/Update Form
- Fadeout Feedback Messages on Contact Add/Update with jQuery and Handlebars
- Using Dandelion with Asset Bundling to load jQuery-UI datePicker and theme
- Custom Favicon
- Custom Exception Handling and all supporting Tests
- Post: Fadeout Feedback Messages in Spring MVC
- Post: Java Dates, Dandelion, Thymeleaf, Hibernate and Spring
- Post: Using Dandelion with Spring Boot and Thymeleaf
- Post: Testing for 404 and Custom Exceptions in Spring MVC
- Post: Custom 404 Exception Handling in Spring MVC
- Post: Including Webjars in IntelliJ Tomcat WAR Artifact
- Post: Using Your Favorite Favicon in Spring MVC
##v0.1.4 -- Contact Display, List and Search##
- jQuery, Bootstrap and Bootswatch Webjars
- Using Bootswatch Webjar with Spring
- Contact Display, List, and Search Form with all supporting Tests
- Post: Adding Bootswatch Webjar in Spring and Thymeleaf
- Post: Bootstrap Navbar Highlighting in Thymeleaf
- Post: Testing a Spring MVC Search Form
##v0.1.3 -- Initial release w/ Thymeleaf##
- Thymeleaf support added
- Post: Thymeleaf Configuration with Spring Boot
##v0.1.2 -- Multi-Module with JPA and MVC Modules##
- MVC Module Added
- JPA and MVC Modules wired as single Spring Application
- Referencing Test Source from JPA module in MVC module tests
- Initial HomeController and ContactController classes
- Pretty Formatted JSON output in Web Browser
- Post: Deployable WARs in Spring Boot, IntelliJ and Gradle
- Post: An IntelliJ Multi Module Spring Boot MVC Configuration
- Post: Referencing Test Classes in Another IntelliJ Module
- Post: Pretty Formatted JSON in Spring Web MVC
##v0.1.1 -- @ManyToMany Hobbies added to Contact Model##
- Addition of Hobbies, a @ManyToMany Entity with Contacts
- Adding Hobbies dynamically on new and updated Contacts, and as separate process
- Adding and removing Hobbies from Contact
- ContactDTO with Set
- Tests covering above Hobby processes
- Post: Working with the Many in a JPA @ManyToMany
##v0.1.0 -- @OneToMany Contact Phones added to Contact Model##
- Examples of Updating, Deleting and Adding records with focus on @OneToMany relationship handling
- ContactDTO now containing Contact and ContactPhone Set
- Builder pattern added to ContactPhone Entity class
- Tests covering Contact updates, deletions and additions, on both contact and multiple contact phones
- Post: Flexible H2 Database Persistence For Testing With Gradle
- Post: Adding a JPA Entity and its @OneToMany Children
- Post: Updating the Many in a JPA @OneToMany
##v0.0.9 -- Lazy Loading examples##
- Several examples of Lazy Loading
- First pass at creating schema DTO objects for use in updating and creating data
- Modified database schema to better adhere to database relationship best practices. Updates are reflected in Entities.
- Post: Approaches to JPA Lazy Loading
##v0.0.8 -- Multi-database configuration w/ H2Console and MySQL##
- h2database and mySQL JPA Data Configuration
- Profiles based on Enumerator value (ex: JpaDataConfig.MYSQL)
- Post: A Spring JPA Configuration for Multiple Profiles
##v0.0.7 -- Multi-profile configuration##
- ApplicationContext and Data Retrieval Tests
- "Production" and "Dev" Spring Profiles
- Re-architected main() to load context, and a single bean to startup application
- Broke out Production and Dev Profile Configurations, extend base SpringConfiguration class. Plan to redesign further
- Spring Profile set in Gradle.build bootRun task
- Post: Spring-Data GitHub App at v0.0.7 with Profiles
- Post: GetBeans in a Spring Main Method, A Better Way
- Post: Setting Spring Profiles in Gradle
##v0.0.6 -- GUI Generated Entities and Diagram Examples##
- Generated supplemental Contact, ContactTelDetail and Hobby Entities using the IntelliJ Persistence View GUI tools. (Models now contain "Entity" classname suffix.)
- Output based on new Entities, shown below
- Updated to Spring 4.1.6, Spring-Boot 1.2.3
- Post: GUI Generated Entities for Spring-Data GitHub App v0.0.6
- Post: IntelliJ ER Diagram Relationship Dialogs and the Code They Create
- Post: Using IntelliJ Persistence View and ER Diagram Mapping Tools
##v0.0.5 -- Hibernate and JPA Module structure##
- Broke-up the application into two separate IntelliJ Modules
- Root and child Gradle project configuration
- Post: Supporting Multiple Transaction Managers in Spring
##v0.0.4 -- Initial Release with JPA##
- Spring Data JPA Implementation
- Dual SpringJPAConfiguration and SpringHbnConfiguration classes
- Simultaneous use of both Spring Data JPA and Hibernate with Transaction Isolation
- Updated MySQL Schema with additional data
- Shared Model Entities between Hibernate and Spring Data JPA
- Spring 4.0.6, Spring-Boot 1.1.4
- Post: JPA Added to Spring Data GitHub App v0.0.4
##v0.0.3 -- DAO Implementation##
- Generic DAO Interface Implementation
- Added Service Facade
- Persistence Tier broken out to Domain Model, Data Access Object and Service Layers
- Data and Output identical to v0.0.1
- Spring 4.0.6, Spring-Boot 1.1.4
- Post: Spring-Data GitHub App at v.0.0.3 with Generic DAO Interface
##v0.0.2 -- Using Spring Properties##
- Populating DataSource connection from Property File
- Using both @Value and @Autowired Environment properties
- Annotations with @ImportResource of app-context.xml file
- Custom SpringPropertiesUtil Class to retrieve overriden "username" System Property
- Populating @Autowired PropertyClass class properties in @Configuration class and retrieving the properties in another class
- Spring 4.0.6, Spring-Boot 1.1.4
- Post: A Spring Property Handling Exercise
- Post: Spring-Data Demo App v0.0.2 on GitHub
##v0.0.1 -- Base Configuration in Spring and Hibernate##
- Changed XML Spring Configuration to Annotations
- Changed datasource from embedded H2 to MySql
- Lazy Fetching
- Named Queries
- Logging Configuration
- Gradle Build Configuration
- Inserting data
- Note: v0.0.1 was created with Spring Boot v1.1.4. Using v1.2.x generates a compile error regarding JPA Entity handling.
- Post: New Spring-Data Demo on GitHub
##Installation##
The application supports an H2 Profile (default) and a MySQL Profile. To run JPA Console app use $gradle jpa:bootRun. To run MVC Web app use $gradle mvc:bootRun. The Tomcat Server Port is set for 8084 (set in the MVC application.properties
file) so go to http://localhost:8084 to view the app in your browser.
##Installation - Database Configuration##
To use MySQL run setup.mysql
script in the /install
directory to populate the database. Update Datasource connection properties in /resources/META-INF/spring/mysql.properties
file. The H2 create-data script for the tests is located in /resources/db.
External properties in /home/daveburke/...external.properties.
Change in JPA common/ApplicationSettings.
Example of external.properties
in /install.
##Installation - External Property File Settings##
The JPA Project demonstrates using an external Property File. To Configure Location of Properties File, change the @PropertySource
annotation setting in Jpa/ApplicationSettings.class
.
@Component
@PropertySource("file:/home/daveburke/web/nixmashspring/external.properties")
@ConfigurationProperties(prefix="external")
public class ApplicationSettings {
##Installation - Solr##
Configure Solr as normally on your development machine. Documents are included in /dev/solr/docs
and scripts to populate the Solr Url and Embedded Servers located in /dev/solr
. Script name: refreshSolr.sh
. It contains additional installation instructions.
The Solr Project demonstrates both Embedded Solr and Http Solr ("dev" and "prod" Profiles respectively.) Configure these in an external solr.properties
file. Same configuration as external.properties file just discussed. Set solr.properties
file location in Solr project common/SolrSettings.java
@PropertySource
value.
##References##
Version 0.0.1 of the app was based on Chapter #7 of Pro Spring, Fourth Edition from Apress, "Using Hibernate." (An excellent book, btw.) Here is the book's listing on Apress. For Safari users, here is the online version of it on Safari.
The Generic DAO structure in Version 0.0.3 was based on Chapter #2 of Spring in Practice by Willie Wheeler and Joshua White, "Data persistence, ORM, and transactions." Here is the Chapter on Safari.
Multiple database JPA Configuration implemented in Version 0.0.8 based largely on the work of Gordon Dickens' Spring-Data-Demos "Profiles" project.
Several components related to Thymeleaf and Security in Version 0.1.x from Arnaldo Piccnelli's Enhanced Pet Clinic.
Petri Kainulainen’s excellent book Spring Data from Packt Publishing and accompanying source code was a reference for Model Attribute handling and feedback messaging in Version 0.1.5 as well as other features.
Two excellent source references for Spring Security which initially appeared in Version 0.1.6 were Rob Winch's gs-spring-security-3.2 something and Bartosz Kielczewski's example-spring-boot-security.
Petri Kainulainen also served as a great reference on Solr in Version 0.2.3. See his excellent Spring Data Solr Tutorial(http://www.petrikainulainen.net/spring-data-solr-tutorial/) on his blog. Another good reference on Solr was Christoph Strobl's spring-data-solr-examples on GitHub.
Spring Framework contributor Christoph Strobl's Spring Data Solr Showcase(https://github.com/christophstrobl/spring-data-solr-showcase) served as the basis of Solr Autocomplete found in Version 0.2.7.