• Stars
    star
    1,053
  • Rank 42,130 (Top 0.9 %)
  • Language
    Java
  • Created over 12 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The project is a Maven archetype for Spring MVC web application.

Spring MVC Quickstart Maven Archetype

Summary

The project is a Maven archetype for Spring MVC web application.

Generated project characteristics

  • No-xml Spring MVC web application
  • Thymeleaf, Bootstrap
  • JPA (Hibernate/HSQLDB/Spring Data JPA)
  • JUnit/Mockito
  • Spring Security
  • MongoDB (Spring Data Mongo)

Prerequisites

  • JDK 8 (tested with Java 11)
  • Maven 3 (tested with 3.6.0)

Create a project

    mvn archetype:generate \
        -DarchetypeGroupId=pl.codeleak \
        -DarchetypeArtifactId=spring-mvc-quickstart \
        -DarchetypeVersion=5.0.1 \
        -DgroupId=my.groupid \
        -DartifactId=my-artifactId \
        -Dversion=version \
        -DarchetypeRepository=http://kolorobot.github.io/spring-mvc-quickstart-archetype

Note: The above command will bootstrap a project using the archetype published here: http://kolorobot.github.io/spring-mvc-quickstart-archetype

Run the project

Navigate to newly created project directory (my-artifactId) and then run:

    mvn test tomcat7:run

Note: I do not recommend this way of running the artifact. Tomcat Maven Plugin Version 2.2 was released on 2013-11-11

Test in the browser

http://localhost:8080/

Note: No additional services are required in order to start the application. Mongo DB configuration is in place but it is not used in the code.

Create a new project in IntelliJ

  • Create new project File > New > Project
  • Click Maven on the left hand side of the new project dialog
  • Check Create from archetype
  • Click the Add Archetype button
  • Set Group Id to pl.codeleak
  • Set Artifact Id to spring-mvc-quickstart
  • Set Version to 5.0.1
  • Set Repository to http://kolorobot.github.io/spring-mvc-quickstart-archetype
  • Click next and create the project

Note: If you would like to create a project using archetype published in your local repository, skip repository field and make sure it is installed locally (see below).

Creating a new project in Spring Tool Suite

  • Create new project File > New > Maven Project
  • Make sure Create a simple project option is not selected
  • Click Next to navigate to Select an Archetype screen
  • Make sure Include snapshot archetypes is selected
  • Click Add Archetype button
  • Set Archetype Group Id to pl.codeleak
  • Set Archetype Artifact Id to spring-mvc-quickstart
  • Set Archetype Version to 5.0.1
  • Set Repository URL to http://kolorobot.github.io/spring-mvc-quickstart-archetype
  • Click OK so the Archetype is added to the list
  • Click Next and fill in Group Id, Artifact Id and Version of your new project

Note: Remember so select Include snapshot archetypes.

If you have any troubles with installation in Eclipse, you may want to have a look at this issue: #74

Install archetype locally

To install the archetype in your local repository execute the following commands:

    git clone https://github.com/kolorobot/spring-mvc-quickstart-archetype.git
    cd spring-mvc-quickstart-archetype
    mvn clean install

Create a project from a local repository

Create a new empty directory for your project and navigate into it and then run:

    mvn archetype:generate \
        -DarchetypeGroupId=pl.codeleak \
        -DarchetypeArtifactId=spring-mvc-quickstart \
        -DarchetypeVersion=5.0.1 \
        -DgroupId=my.groupid \
        -DartifactId=my-artifactId \
        -Dversion=version

Note: The above command will bootstrap a project using the archetype published in your local repository.

Switching to PostgreSQL

  • Add dependency to PostgreSQL driver in POM:
<dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>9.4.1207</version>
</dependency>
  • Change persistence.properties:
dataSource.driverClassName=org.postgresql.Driver
dataSource.url=jdbc:postgresql:postgres
dataSource.username=postgres
dataSource.password=postgres

hibernate.dialect=org.hibernate.dialect.PostgreSQL9Dialect
hibernate.hbm2ddl.auto=create
hibernate.show_sql=true
hibernate.format_sql=true
hibernate.use_sql_comments=true

Enabling MongoDB repositories

  • Open MongoConfig class and uncomment the following line:
// @EnableMongoRepositories(basePackageClasses = Application.class)

Now you can add repositories to your project:

@Repository
public interface MyRepository extends MongoRepository<MyDocument, String> {

}

More Repositories

1

spring-boot-thymeleaf

A simple web application in Spring Boot and Thymeleaf
Java
315
star
2

angular2-typescript-gulp

A basic Angular2 application with Gulp as build system.
TypeScript
120
star
3

unit-testing-demo

Java
68
star
4

thymeleaf-custom-layout

Java
56
star
5

openshift-diy-spring-boot-sample

Java
42
star
6

spring-mvc-beanvalidation11-demo

Java
33
star
7

spring-boot-jersey-demo

Java
31
star
8

spring-boot-petclinic-api

Java
21
star
9

openshift-diy-spring-boot-gradle

Shell
19
star
10

quarkus-petclinic-api

Pet Clinic API with Quarkus and Hibernate (Panache), Flyway, RESTEasy (+Jackson), Swagger, PostgreSQL
Java
17
star
11

quartz-jee-demo

Quartz with Clustering JEE demo application
SQL
16
star
12

spring-boot-tc

Spring Boot tests with Testcontainers and PostgreSQL
Java
14
star
13

junit5-samples

Java
12
star
14

spring-boot-junit5

Java
12
star
15

vite-node-starter

Starter template for prototyping and building CLI tools with Node.js and TypeScript
TypeScript
10
star
16

spring41-samples

Java
7
star
17

angular2-typescript-webpack

Source code for https://angular.io/docs/ts/latest/guide/webpack.html
JavaScript
6
star
18

spring-boot-angular

Java
5
star
19

quarkus-postgres-sample

Quarkus based project that uses Postgres, Hibernate with Panache and RESTEasy Jackson extension
HTML
4
star
20

spring-mvc-icm-demo

Java
4
star
21

openshift-wildfly-spring-boot

HTML
3
star
22

spring-boot-demo

Java
3
star
23

java9-and-beyond

Java
3
star
24

junit5-selenium-todomvc-demo

Java
3
star
25

junit5-gradle-template

Basic JUnit 5 Gradle template to bootstrap a project
Java
2
star
26

junit5-playwright-demo

Java
2
star
27

permalink

Permanent link generator to Google Drive resources (e.g. images)
HTML
1
star
28

angularjs-explained

JavaScript
1
star
29

spring-boot-kotlin-petclinic-api

Kotlin
1
star
30

jest-js-starter

JavaScript
1
star
31

sahi-script-samples

The scripts that I presented during my talk at TrojQA (http://trojqa.pl/?p=642)
JavaScript
1
star
32

parcel-starters

JavaScript
1
star