A Spring starter project with XML based configuration to get you upp and running for a small to medium scale spring application with a database and spring security for those who do not want to use Spring-Boot
- Spring Framework (4.3.10.RELEASE)
- Hibernate
- Spring security
- taglibs
- log4j
- slf4j
- fasterxml jackson
- Mail sender
- GZip for web compression
Dependencies can be changed as you like update to current version if you like
- Clone the repo:
git clone https://github.com/Recks11/SpringMVC-Starter.gitor download it - Import on Intellij Idea from external sources as a maven project and enable auto import when asked. if you are not asked go to
Preferences > Build, execution, deployment > Build Tools > Maven > Importingand tickImport maven projects automatically - In the
POM.xmlfile change the spring version to the version you want to use this repo uses the 4.3.10.RELEASE - !IMPORTANT Create the web facet, In Intellij IDEA go to
File > Project Structure > Facetsand add a web facet - In the web facet change the
web resource directoryto the location of theweb.xmlfile which issrc/main/webappand theweb module deployment descriptorto theweb.xmlfile itself insrc/main/webapp/WEB-INF/web.xml - you will also see an error saying there is no artifact here click create artifact
- In
File > Project Structure > artifactsselect all available artifacts and add to lib or just double click them one at a time - Create a new run configuration from
run > Edit configurationsclick the+and selectTomcat > localif you have tomcat installed select tomcat home (where its installed or extracted to) in the before lunch section you'll see an error click fix to select the artifact to use for deployment - Press apply then press OK and now run the application. you should immediately land in the 'IT WORKS page'.
- Happy development
Coming soon...
- Uncomment the hibernate dependencies in the
Pom.xmlfile - Uncomment the Database configuration section in the
applicationContext.xmlfile - Go to the
hibernate.propertiesfile - Enter the database url in
jdbc.urlan example isjdbc:mysql://localhost:3306/DatabaseName?useSSL=false - Enter the database username in
jdbc.username - Enter the database password in
jdbc.username - Thats all! You can now use hibernate for the selected database
I prefer using a hibernate.properties file instead of directly editing the appliocationContext file because the database can be changed at any point in time by just changing or editing only that file
Coming soon...
This is the overall project structure. the full project naming scheme can be refactored to suit your needs
SpringMVC Starter/
├── src/
│ ├── main/
│ │ └── com/
│ │ └── name/
│ │ ├── controllers/
│ │ │ └── indexController.java
│ │ └── data/
│ │ ├── model/
│ │ │ └── user.java
│ │ ├── repository
│ │ └── services
│ │
│ ├── resources/
│ │ ├── hibernate.properties
│ │ ├── jdbc.properties
│ │ └── log4j.properties
│ │
│ ├── webapp/
│ │ ├── resources/
│ │ │ ├── css/
│ │ │ ├── js/
│ │ │ └── media/
│ │ │
│ │ └── WEB-INF/
│ │ ├── spring/
│ │ │ ├── applicationContext.xml
│ │ │ └── dispatcher-servlet.xml
│ │ ├── views/
│ │ │ └── index.jsp
│ │ └── web.xml
│ │
│ └── test/
│ └── java/
│
└── pom.xml