Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 错误:无法找到或加载主类Spring启动应用程序_Java_Maven_Spring Boot - Fatal编程技术网

Java 错误:无法找到或加载主类Spring启动应用程序

Java 错误:无法找到或加载主类Spring启动应用程序,java,maven,spring-boot,Java,Maven,Spring Boot,我有一个Spring启动应用程序,我不明白为什么会出现这样的“错误:无法找到或加载主类com.example…” 我只是在用maven打包的jar文件中遇到了这个问题,它包含了所有依赖项。与STS中的整个项目一样,没有依赖项的jar文件工作正常。我已经阅读了这个问题()和所有相关的文章,它仍然在我的脑海中。我做了所有建议,但最后还是犯了同样的错误。我现在在创建的jar中的MANIFEST.MF中有了Main类:com.full.qualified.name 我可能有一个类路径问题,正如我从那篇文

我有一个Spring启动应用程序,我不明白为什么会出现这样的“错误:无法找到或加载主类com.example…”

我只是在用maven打包的jar文件中遇到了这个问题,它包含了所有依赖项。与STS中的整个项目一样,没有依赖项的jar文件工作正常。我已经阅读了这个问题()和所有相关的文章,它仍然在我的脑海中。我做了所有建议,但最后还是犯了同样的错误。我现在在创建的jar中的MANIFEST.MF中有了
Main类:com.full.qualified.name

我可能有一个类路径问题,正如我从那篇文章中感觉到的,当我在maven插件中包含
true
时,我在MANIFEST.MF文件中得到了大约150多个依赖项jar文件作为类路径。这些jar文件也在我的jar\Boot-INF\lib中,而我的代码文件在jar\Boot-INF\classes中。你认为这与此有关吗?我如何解决这个问题

我的POM:

<?xml version="1.0" encoding="UTF-8"?>
<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>com.fully.qualified</groupId>
<artifactId>name</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>example</name>
<description>Demo project for Spring Boot</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.2.RELEASE</version>
    <relativePath/>
    <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
    <scala.majorVersion>2.11</scala.majorVersion>
    <scala.minorVersion>8</scala.minorVersion>
    <start-class>com.fully.qualified.name.Demo</start-class>
</properties>

<pluginRepositories>
    <pluginRepository>
        <id>scala-tools.org</id>
        <name>Scala-tools Maven2 Repository</name>
        <url>http://scala-tools.org/repo-releases</url>
    </pluginRepository>
</pluginRepositories>

<repositories>
<repository>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <id>central</id>
        <name>Central Repository</name>
        <url>https://repo.maven.apache.org/maven2</url>
    </repository>
    <repository>
        <id>pele.farmbio.uu.se</id>
        <url>http://pele.farmbio.uu.se/artifactory/libs-snapshot</url>
    </repository>
    <repository>
        <id>scala-tools.org</id>
        <name>Scala-tools Maven2 Repository</name>
        <url>http://scala-tools.org/repo-releases</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>org.scala-lang</groupId>
        <artifactId>scala-library</artifactId>
        <version>${scala.majorVersion}.${scala.minorVersion}</version>
        <exclusions>
            <exclusion>
                <groupId>com.sun.jersey</groupId>
                <artifactId>jersey-server</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-server</artifactId>
        <version>1.19.3</version>
    </dependency>
    <dependency>
        <groupId>commons-codec</groupId>
        <artifactId>commons-codec</artifactId>
        <version>1.5</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.lamma</groupId>
        <artifactId>lamma_2.11</artifactId>
        <version>2.2.2</version>
    </dependency>

    <!-- fix java.lang.ClassNotFoundException: org.codehaus.commons.compiler.UncheckedCompileException -->
    <dependency>
        <groupId>org.codehaus.janino</groupId>
        <artifactId>commons-compiler</artifactId>
        <version>2.7.8</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.slf4j/log4j-over-slf4j -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>log4j-over-slf4j</artifactId>
        <version>1.7.25</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.5</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.6.4</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.5</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
            <executions>
                <execution>
                    <id>default-compile</id>
                    <phase>none</phase>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>net.alchim31.maven</groupId>
            <artifactId>scala-maven-plugin</artifactId>
            <version>3.2.2</version>
            <configuration>
                <recompileMode>incremental</recompileMode>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>compile</goal>
                        <goal>testCompile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
            <archive>
                <manifest>
                    <addClasspath>true</addClasspath>
                    <mainClass>com.fully.qualified.name.Demo</mainClass>
                </manifest>

            </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
            <executions>
                <execution>
                    <id>assemble-all</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
        </plugin>
    </plugins>

<!-- Following is to remove pom errors only -->
    <pluginManagement>
        <plugins>
            <!--This plugin's configuration is used to store Eclipse m2e settings 
                only. It has no influence on the Maven build itself. -->
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>
                                        net.alchim31.maven
                                    </groupId>
                                    <artifactId>
                                        scala-maven-plugin
                                    </artifactId>
                                    <versionRange>
                                        [2.15.2,)
                                    </versionRange>
                                    <goals>
                                        <goal>compile</goal>
                                        <goal>testCompile</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <ignore></ignore>
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

4.0.0
完全合格
名称
0.0.1-快照
罐子
例子
SpringBoot的演示项目
org.springframework.boot
spring启动程序父级
1.5.2.1发布
UTF-8
UTF-8
1.8
2.11
8.
com.full.qualified.name.Demo
scala-tools.org
Scala工具Maven2存储库
http://scala-tools.org/repo-releases
假的
中心的
中央知识库
https://repo.maven.apache.org/maven2
贝利农场生物uu.se
http://pele.farmbio.uu.se/artifactory/libs-snapshot
scala-tools.org
Scala工具Maven2存储库
http://scala-tools.org/repo-releases
org.scala-lang
scala图书馆
${scala.majorVersion}.${scala.minorVersion}
泽西岛
泽西服务器
泽西岛
泽西服务器
1.19.3
通用编解码器
通用编解码器
1.5
org.springframework.boot
SpringBootStarterWeb
org.springframework.boot
弹簧起动试验
测试
南丫岛
南丫岛2.11
2.2.2
org.codehaus.janino
通用编译器
2.7.8
org.slf4j
log4j-over-slf4j
1.7.25
org.slf4j
slf4j api
1.7.5
org.slf4j
slf4j简单
1.6.4
org.springframework.boot
弹簧启动装置
org.springframework.boot
springbootmaven插件
org.apache.maven.plugins
maven编译器插件
3.5
1.8
1.8
默认编译
没有一个
net.alchim31.maven
scala maven插件
3.2.2
增量的
编译
测试编译
org.apache.maven.plugins
maven汇编插件
真的
com.full.qualified.name.Demo
带有依赖项的jar
集合所有
包裹
单一的
org.apache.maven.plugins
maven jar插件
org.eclipse.m2e
生命周期映射
1.0.0
net.alchim31.maven
scala maven插件
[2.15.2,)
编译
测试编译

Java命令:
Java-jarexample-0.0.1-SNAPSHOT-jar-with-dependencies.jar

java-jarexample-0.0.1-SNAPSHOT.jar
工作正常


谢谢。

请将您的POM和启动时使用的命令包括在内,请查看。您是否尝试过“mvn spring boot:run”?是的,它确实可以工作,但我也可以直接从STS运行它。目标是在Azure上部署它,为此我需要一个工作jar文件。该文件甚至不在本地主机上工作。Azure上的调试稍后会进行:-(请,包括您的POM和用于启动的命令,请查看。您尝试了吗“mvn spring boot:run”?是的,它确实可以运行,但我也可以直接从STS运行它。目标是在Azure上部署它,为此我需要有一个工作的jar文件。它甚至不能在本地主机上运行。在Azure上进行调试