Springboot Project Configuration

1 minute read

Written by SGLee, VCANUS

Springboot Project Configuration

Project generation

Steps

  1. new project -> maven project image
  2. check name, location, groupId image

Maven setup

install

  1. download binary file from apache maven (https://maven.apache.org/download.cgi)
  2. decompress file to installation folder (ex: /opt/)
  3. check privilege of the folder. use “chown -R userId:groupId folder name” if your id don’t have the privilege.
  4. make a symbolic link for easy access
     $ ln -s apache-maven-x.x.x maven
    

configuration and use Maven in IntelliJ

  1. update environment variable. modify .bash_profile(MAC) or .bashrc(Ubuntu)
     $ vi ~/.bash_profile
    
     MAVEN_HOME=/opt/maven
     export PATH=$MAVEN_HOME/bin:$PATH
    
  2. use Maven command Terminal in Intellij
     $ mvn clean
     $ mvn compile // to make class file
     $ mvn package // to make jar or war file
    

IntellJ configuration to make package

configuration pom.xml

add ... to pom.xml You will see a message "no main manifest attribute, in xx.jar" when you run xx.jar file after "mvn package". pom.xml

      <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

add annotation to main class

@SpringBootApplication @ComponentScan(basePackages = {“com.vcanus”})

 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.annotation.ComponentScan;

 @SpringBootApplication
 @ComponentScan(basePackages = {"com.vcanus"})
 public class Application {
     public static void main(String[] args) {
         System.out.println("Hello World");
         ApplicationContext context = SpringApplication
                 .run(Application.class, args);
     }
 }

IntelliJ Configuration to deploy package to Github

make Github token

(https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line)

setup .m2/settings.xml

(https://help.github.com/en/packages/using-github-packages-with-your-projects-ecosystem/configuring-apache-maven-for-use-with-github-packages)

run mvn

$ mvn clean 
$ mvn compile
$ mvn package
$ mvn deploy

Leave a comment