maven build하여 생성한 jar를 java -jar test.jar 하여 실행하는 경우 다음과 같은 오류 발생
Spring boot에서 메인클래스를 찾지 못하여 발생하는 문제
pom.xml에 다음의 코드를 추가하여 메인클래스를 알려준다.
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <fork>true</fork> <mainClass>com.example.demo.DemoApplication</mainClass> </configuration> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.2-beta-5</version> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <mainClass>com.example.demo.DemoApplication</mainClass> </manifest> </archive> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> <executions> <execution> <id>assemble-all</id> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
정상적으로 올라가는것을 확인할 수 있다.
* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.