Springboot Project Configuration
Written by SGLee, VCANUS
Springboot Project Configuration
Project generation
Steps
- new project -> maven project
- check name, location, groupId
Maven setup
install
- download binary file from apache maven (https://maven.apache.org/download.cgi)
- decompress file to installation folder (ex: /opt/)
- check privilege of the folder. use “chown -R userId:groupId folder name” if your id don’t have the privilege.
- make a symbolic link for easy access
$ ln -s apache-maven-x.x.x maven
configuration and use Maven in IntelliJ
- update environment variable. modify .bash_profile(MAC) or .bashrc(Ubuntu)
$ vi ~/.bash_profile
MAVEN_HOME=/opt/maven export PATH=$MAVEN_HOME/bin:$PATH
- 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
<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