小编Lev*_*ian的帖子

maven:没有主要清单属性

我正在处理我的 web java 项目。当我尝试运行 maven 构建的 java jar 文件时,出现错误:

no main manifest attribute, in "project name".
Run Code Online (Sandbox Code Playgroud)

我认为原因是 maven 找不到我的主要课程。我已经用这个层次结构创建了测试项目:

/test
    /src
        /main
             Main.java
    pom.xml
Run Code Online (Sandbox Code Playgroud)

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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>FirstProject</groupId>
<artifactId>FirstProject</artifactId>
<version>1.0</version>

<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugin</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.4</version>
        </plugin>
        <plugin>

            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
                    <outputDirectory>${basedir}</outputDirectory>
                    <finalName>server</finalName>
                    <appendAssemblyId>false</appendAssemblyId>
                 <archive>
                        <manifest>
                            <mainClass>main.Main</mainClass>
                        </manifest>
                    </archive>
                </configuration>
    </plugin>
    </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)

在测试项目中也会得到这个错误。我试图用谷歌搜索它,每个人都建议在 pom.xml 中添加,但我已经这样做了……(在我的情况下,这不是解决方案)。我怎么解决这个问题?

java manifest pom.xml maven

6
推荐指数
2
解决办法
1万
查看次数

在数组中查找两个元素,恰好出现一次

最近我接到了以下任务:

假设您有一个长度为N的元素数组,其中除了两个special之外的每个元素都出现一次,恰好出现两次。找到这个特殊号码。

我也知道数组中的每个元素都是非负的,并且不超过 10^9 并且数组的长度,N小于或等于 10^6

我认为解决方案是使用 xors。这是我的想法:

让我们对数组中的所有元素进行异或。由于 xor 是可交换的,例如 xor(a, b)=xor(b, a),我们可以得出结论,所有出现两次的元素都将归零:

xor(a, b, a, c)=xor(a, a, b, c)=xor(xor(a, a), b, c)=xor(0, b, c)=xor(b, c) )

然后对整个数组进行异或运算,我们将得到两个特殊元素的异或。接下来做什么?也许,其他一些解决方案?

PS请不要告诉我有关哈希表的任何信息。首先,我已经尝试过了,但是没有用,因为我的哈希函数无法将所有范围的数字压缩到任何合理大小的数组中(至少对于我的机器而言)。其次,它被任务的条件所禁止。

编辑:我的错,我没有提到排序也被禁止。

c algorithm xor

2
推荐指数
1
解决办法
162
查看次数

标签 统计

algorithm ×1

c ×1

java ×1

manifest ×1

maven ×1

pom.xml ×1

xor ×1