简体   繁体   English

maven-jar-plugin 不生成清单

[英]maven-jar-plugin does not generate MANIFEST

I cant generate MANIFEST file using maven... I try everything and I didnt find the solution.我无法使用 maven 生成 MANIFEST 文件...我尝试了所有方法,但没有找到解决方案。 The jar file is generate correct, but manifest is missing. jar 文件生成正确,但缺少清单。

This is the part of my pom.xml:这是我的 pom.xml 的一部分:

    <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <useDefaultManifestFile> true </useDefaultManifestFile>
                <!-- archive> <manifest> <mainClass>net.menago.core.main.Menago</mainClass> 
                    </manifest> 
                </archive -->
                <!-- archive>
                    <index>true</index>
                    <manifest>
                        <addClasspath>true</addClasspath>
                    </manifest>
                    <manifestEntries>
                        <mode>development</mode>
                        <url>${project.url}</url>
                        <key>value</key>
                    </manifestEntries>
                </archive-->
            </configuration>
        </plugin>

As you can see there are some commented codes which does not work too.如您所见,有一些注释代码也不起作用。 I've tried mvn clean install, compile, package...我试过 mvn clean install, compile, package ...

Thanks for any advice!感谢您的任何建议!

检查您的包装元素是否设置了价值包

<packaging>bundle</packaging>

Use this instead:改用这个:

<plugins>
  <plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.9.0</version>
    <configuration>
      <source>${java.version}</source>
      <target>${java.version}</target>
    </configuration>
  </plugin>
  <plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
  </plugin>
</plugins>

May be this will work可能这会奏效

<configuration> 
                    <archive> 
                      <manifest> <mainClass>net.menago.core.main.Menago</mainClass>                                  
                        <index>true</index>                  
                            <addClasspath>true</addClasspath>                   
                        <manifestEntries>
                            <mode>development</mode>
                            <url>${project.url}</url>
                            <key>value</key>
                        </manifestEntries>
                      </manifest>
                    </archive>
      </configuration>

Clearly your pasted segment will not work due to the comments, so I make the assumption that you have posted what you have to show what you have been trying to use.显然,由于评论,您粘贴的部分将不起作用,因此我假设您已经发布了您必须展示的内容以显示您一直在尝试使用的内容。

The correct usage of <manifestEntries> is as so: <manifestEntries>的正确用法是这样的:

      <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <archive>
                    <manifestEntries>
                        <yourKey>your value</yourKey>
                    </manifestEntries>
                </archive>
            </configuration>
      </plugin>

This is at odds with your concurrent use of <useDefaultManifestFile> which will produce a standard output.这与您同时使用将产生标准输出的<useDefaultManifestFile>不一致。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM