mvn package
java -jar target/java_bottom_level_learning-1.0-SNAPSHOT.jar

这里报错了:
target/java_bottom_level_learning-1.0-SNAPSHOT.jar中没有主清单属性

我们打开 jar 中的 /META_INF/ MANIFEST.MF缺少项目启动项,即没有Main-Class

怎么处理呢?
maven有一个插件,咱们把他用起来(有别于其他修改 IDEA 的方案,毕竟我们是要不依赖 IDEA 也能正常使用):
修改pom.xml,project 节点中添加如下内容:

<build>
        <finalName>${project.artifactId}</finalName><!--修改编译出来的jar包名,仅为{artifactId}.jar-->
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.2.0</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>org.whq.learning.helloworld.MainApplication</mainClass> <!-- 此处为主入口-->
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>

再次编译执行

mvn package
java -jar target/java_bottom_level_learning.jar
/**输出
hello world
error
**/

此时打开 jar 包,里面也多了 Main-Class: org.whq.learning.helloworld.MainApplication,说明刚才新加的主入口配置有效并且作用在这里了。