This is my first day with SpringBoot, I try to understand the architecture so I started building a hello world application:
In my pom.xml, under maven-shade-plugin I state mainClass as follows:
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.demo.HelloWorld</mainClass>
</transformer>
And here's the groupId and artifactId values of the pom file:
<groupId>com.demo</groupId>
<artifactId>demo</artifactId>
When I package with maven ( mvn package ) and run the war file (target/demo.war), I get the following error:
Error: Could not find or load main class com.demo.HelloWorld
The file destination is src/main/java/com/demo/HelloWorld.java , and the code in that file is:
package com.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class HelloWorld {
public static void main(String[] args) {
SpringApplication.run(HelloWorld.class, args);
}
}
What am I missing?
尝试使用spring-boot maven插件-> link ,它使可执行jar无需任何配置。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.