原创

Jar 可执行文件(在类中具有 main 方法)未在 JBoss EAP 7 上运行

温馨提示:
本文最后更新于 2024年04月12日,已超过 37 天没有更新。若文章内的图片失效(无法正常加载),请留言反馈或直接联系我

i have create a jar executable archive (jar), ie one java class with a main method. If i execute it by java -jar command, i see the system.out.println in the main method, otherwise, if this jar is deployed in JBoss EAP 7, when the server is started, the system.out.println not appears to che console. The path of main class is in manifest.mf under META-INF directory jar. Why JBoss not execute the jar?

main class

package com.package;
public class MainClass {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
         System.out.println("Hello, world!");
    }

}

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.package</groupId>
  <artifactId>my-jar-project</artifactId>
  <version>1.0.0</version>
  <build>
  <finalName>my-proj-jar</finalName>
    <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>com.package.MainClass</mainClass>
                </manifest>
            </archive>
        </configuration>
    </plugin>
    </plugins>
  </build>
</project>

MANIFEST.MF

Manifest-Version: 1.0
Build-Jdk-Spec: 1.8
Created-By: Maven Jar Plugin 3.2.0
Main-Class: com.package.MainClass

maven generate a Jar.

The Jar is deployed correctly on JBoss, but the System.out.println not printed where the Application Server is started.

正文到此结束
热门推荐
本文目录