DEV Community

Gabi
Gabi

Posted on • Updated on

Create a SpringBoot, Flyway project in a couple of minutes on Github

Alt Text
WHY?
Starting a new project from scratch is a awesome feeling, and a daunting one when you think of ALL of the configurations, installing you need to do. I was there a lot of times and decided to create a GitHub Template repository for a SpringBoot project that uses Flyway migrations, PostgreSql and Java (at least version 11, but will go with 8 as well) and Maven.

HOW?
The process is straight forward, you create a new repository and work on your project as you would normally do. The difference is when you decide that this is the base of any project with these technologies, then you can keep this snapshot and flag the repository as a "Template Project".
From this moment on, you can Fork, download locally etc and continue with your development but know you can always come back to the base in the future. For me personally this is great, because I spend less time on redundant tasks and more on creating and implementing useful features.

ABOUT THIS PROJECT
The project returns a list of remote developers and lets you search in the list by first name. This was arbitrary for me to choose and you will need to rename and create new objects as needed.

Requirements:

  • Java installed. I used Java 11
  • Postgresql driver installed
  • A terminal (GitBash etc)
  • An editor (IntelliJ etc)
  • A data scheme already created with name: postgres

Steps for getting started with it in Windows:

  1. git clone https://github.com/gabrielaradu/MyTemplateWithSpringAndPersistence.git
  2. Add env variables for:
    REMOTEDEV_M_DB_SERVER: localhost
    REMOTEDEV_M_DB_USER: postgres
    REMOTEDEV_M_DB_PASS: admin
    REMOTEDEV_M_DB_PORT: 5433

  3. Import/Open your project in your editor

  4. Create SpringBoot application config with below details if you want to run the project from outside of a command line
    Main Class: com.remote.developers.TemplateProjectApplication
    JRE: 11

For more information on how to create more development environments in the project checkout this post: https://dev.to/gabriela/spring-boot-rest-api-and-flyway-migrations-a3a

Try running the unit tests and the integration tests that already exist. They should pass, by the way :)

Flyway is already configured and your first table will be created when running the application. The script is in resources/db.migration/V1__InitDatabase.sql After successfully running the application, an entry will be added in the table "flyway_schema_history". For much more details about Flyway please check their docs: https://flywaydb.org/

  1. When you want to add more endpoints you need to allow them in the WebSecurityConfiguration class specifically or else you will get a HttpsStatus 404 back on trying to reach them.

All the names and credentials from above should be renamed and made more complex and unique for your project.

Code can be found here: https://github.com/gabrielaradu/TemplateWithSpringAndPersistence

WHAT'S NEXT?
In time you can add as much functionality as you want. It's your call.
Happy coding.

Latest comments (0)