sorabh86 / spring-boot-gradle-mvn

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Maven and Gradle

This is practise project to refreshing springboot development using both maven and gradle. We are going to make a simple web based application and setup a basic manually configuration to understand at command line.

Packages

  • spring-boot-starter-web : uses for web applications
  • spring-boot-devtools : it restart the development server on each build change, if you are running your project using command mvn spring-boot:run or gradle bootRun without any IDE, use the mvn install or gradle build command after each save on another terminal.

Maven Commands

  • Running the app
mvn spring-boot:run
  • Install dependency
mvn clean install
  • Check the dependency tree
mvn dependency:tree
  • Build standlone jar (it will create in folder target/{artifactId}.jar)
mvn package
  • Running the standlone app
java -jar {path_to_your_jar_file}
  • Environment variable
export MAVEN_OPTS=-Xmx1024m

Steps for Maven Spring boot Project

  1. create a folder, choose a name.
  2. create a pom.xml file (ref:file:springboot-ex1-mvn/pom.xml)
  3. create a javafile MyApplication.java (ref:file:springboot-ex1-mvn/src/main/java/mymvnapp/MyApplication.java)
  4. run mvn spring-boot:run

Gradle Commands

  • Running app
gradle bootRun
  • Check Dependencies
gradle dependencies
  • Clean & Install Dependencies
gradle clean build
  • Build a standlone jar (build/libs/{name_of_root_folder}.jar)
gradle bootJar
  • Run Standlone jar
java -jar {path_to_jar_file}
  • Environment Variables
export JAVA_OPTS=-Xmx1024m

Steps for Gradle on Spring boot

  1. Create a folder
  2. Make a build.gradle file (ref:./springboot-ex2-gradle/build.gradle)
  3. Make a MyApplication.java file (ref:./springboot-ex2-gradle/src/main/java/MyApplication.java)
  4. Run the application using gradle bootRun

About


Languages

Language:Java 100.0%