关于使用Idea中maven工具打包没有主类的问题

包装出来的jar包没有主类

(1)没有配置阿里云仓库

	如果没有配置相应的阿里云仓库则可能无法下载相关的依赖。
我出现的问题就是无论如何找不到assembly的plugin,而要使jar
包含有主类的必要条件就是需要用到这个plugin。
	所以首先需要在依赖中添加以下代码,
  <repositories>
      <repository>
      <id>nexus-aliyun</id>
      <name>nexus-aliyun</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
      <releases>
        <enabled>true</enabled>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </repository>
  </repositories>

(2)没有利用maven-assembly-plugin这个插件添加主类!

添加以下代码!!!可以让你的主类包含在jar包中。
	<plugin>
          <artifactId>maven-assembly-plugin</artifactId>
          <version>3.0.0</version>
          <configuration>
            <archive>
              <manifest>
                <mainClass>org.example.CalenderTest</mainClass>
              </manifest>
            </archive>
            <descriptorRefs>
              <descriptorRef>jar-with-dependencies</descriptorRef>
            </descriptorRefs>
          </configuration>
          <executions>
            <execution>
              <id>make-assembly</id>
              <phase>package</phase>
              <goals>
                <goal>single</goal>
              </goals>
            </execution>
          </executions>
	</plugin>

(3)生成了含有“with-dependencies.jar”这个后缀的jar包!

可以在configuration标签下添加如下内容

<appendAssemblyId>false</appendAssemblyId>

(4)如果以上均没有问题可以试试再 pluginManagement标签下添加一个plugins与其同级的标签!

*一定要在pluginManagement外面添加

    <plugins>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>3.0.0</version>
      </plugin>
    </plugins>
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

躺平崽

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值