Search code examples
javaspringspring-bootspring-mvcsystem-design

How to convert a Java console application to a Full Stack web application using Spring Framework?


So the project I want to convert is at https://github.com/zhongjis/keyword_search_engine_xlsm.

This program intends to build a search engine based on the user input files (xlsm). It extracts content from an XLSM (excel) file first and stores them to the DB. while building up the database, the program will also calculate some special numbers such as td-idf which will be used later for result ranking.

Current technology used:

  • Gradle
  • Java 13
  • MongoDB

What I am trying to do?

  • convert this console application to a full-stack web application that uses Spring Framework. which means that I want to add a GUI.
  • I am trying to keep as much original code as possible during this transition. For me, it is ok to modify them to fit the MVC design.
  • In one sentence, I want to make my current application runs on the Spring framework. it is OK only to have console output.

What are my questions?

  • even though I did a lot of research on Spring Framework (especially Spring boot). But I am still struggles with what should I do first in order to implement the framework. I would like some suggestions on how to start (or what should I change on my original project). All I learned from the internet is adding various dependencies to build.gradle. But I still have no idea what to do next. Should I start a new Web Application from scratch or try to convert the current one?

Thank you

  • I tried my best to fill in details. However, this post might still be vague or confusing on some parts and need some clarification. Please feel free to let me know and I am more than willing to do that :)

Solution

  • It appears that you want to create a Web Application.

    The easiest way to get started is to use Spring Boot, which is the 'opinionated' version of Spring, meaning that it uses smart defaults. You should start by using the Initializer to generate your project: https://start.spring.io/. Keep generating and testing until you get what you want.

    The simplest method is to build an executable JAR, which will contain your web server and can be run anywhere you have Java. This is the default setting on Initializer site above. My advice: Accept Spring Boot defaults until you know what you're doing.

    GUI: The simplest method is to use Thymeleaf templates to display your HTML.

    Controller: Learn how to write a basic controller to return a Thymeleaf template. The simplest way to begin is with standard HTML posting to your controller.

    Docs A great strength of Spring is the ample documentation. See: https://spring.io/guides/gs/serving-web-content/ and: https://docs.spring.io/spring/docs/current/spring-framework-reference/web.html