简体   繁体   English

显示错误将spring-boot作为java应用程序启动

[英]Manifest error lanching spring-boot as java application

I can't run my Spring Boot application in my eclipse 3.9.0RELEASE. 我无法在我的eclipse 3.9.0RELEASE中运行我的Spring Boot应用程序。 It runs fine if launched on Prompt with the command: 如果使用以下命令在Prompt上启动它,它运行正常:

mvn spring-boot:run mvn spring-boot:运行

But I prefer using my Spring Client instead of the Command Prompt, and when I try to run it, doing: Run As-> Java Application or Spring Boor App , then i get this error: 但我更喜欢使用我的Spring Client而不是命令提示符,当我尝试运行它时,执行:运行As-> Java Application或Spring Boor App,然后我收到此错误:

ERROR StatusLogger No log4j2 configuration file found. 错误StatusLogger找不到log4j2配置文件。 Using default configuration: logging only errors to the console. 使用默认配置:仅将错误记录到控制台。 Exception in thread "main" java.lang.IllegalStateException: Failed to read Class-Path attribute from manifest of jar file:/C:/Users/MyFirstName%20MySecondName/.m2/repository/org/codehaus/groovy/groovy/2.4.7/groovy-2.4.7.jar at org.springframework.boot.devtools.restart.ChangeableUrls.getUrlsFromClassPathOfJarManifestIfPossible(ChangeableUrls.java:100) at org.springframework.boot.devtools.restart.ChangeableUrls.fromUrlClassLoader(ChangeableUrls.java:88) at org.springframework.boot.devtools.restart.DefaultRestartInitializer.getUrls(DefaultRestartInitializer.java:91) at org.springframework.boot.devtools.restart.DefaultRestartInitializer.getInitialUrls(DefaultRestartInitializer.java:54) at org.springframework.boot.devtools.restart.Restarter.(Restarter.java:134) at org.springframework.boot.devtools.restart.Restarter.initialize(Restarter.java:531) at org.springframework.boot.devtools.restart.RestartApplicationListener.onApplicationStartedEvent(RestartApplicationListener.java:64) at org.spring 线程“main”中的异常java.lang.IllegalStateException:无法从jar文件的清单中读取Class-Path属性:/ C:/Users/MyFirstName%20MySecondName/.m2/repository/org/codehaus/groovy/groovy/2.4。 7 / groovy-2.4.7.jar at org.springframework.boot.devtools.restart.ChangeableUrls.getUrlsFromClassPathOfJarManifestIfPossible(ChangeableUrls.java:100)at org.springframework.boot.devtools.restart.ChangeableUrls.fromUrlClassLoader(ChangeableUrls.java:88 )org.springframework.boot.devtools.restart.DefaultRestartInitializer.getUrls(DefaultRestartInitializer.java:91)atg.springframework.boot.devtools.restart.DefaultRestartInitializer.getInitialUrls(DefaultRestartInitializer.java:54)at org.springframework.boot。 devtools.restart.Restarter。(Restarter.java:134)org.springframework.boot.devtools.restart.Restarter.initialize(Restarter.java:531)org.springframework.boot.devtools.restart.RestartApplicationListener.onApplicationStartedEvent(RestartApplicationListener) .java:64)在org.spring framework.boot.devtools.restart.RestartApplicationListener.onApplicationEvent(RestartApplicationListener.java:46) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:166) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:121) at org.springframework.boot.context.event.EventPublishingRunListener.publishEvent(EventPublishingRunListener.java:111) at org.springframework.boot.context.event.EventPublishingRunListener.started(EventPublishingRunListener.java:60) at org.springframework.boot.SpringApplicationRunListeners.started(SpringApplicationRunListeners.java:48) at org.springframework.boot.SpringApplication.run(SpringApplication.java:302) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185) at 位于org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:166)的framework.boot.devtools.restart.RestartApplicationListener.onApplicationEvent(RestartApplicationListener.java:46)org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent( SimpleApplicationEventMulticaster.java:138)org.springframework上的org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:121)org.springframework.boot.context.event.EventPublishingRunListener.publishEvent(EventPublishingRunListener.java:111) org.springframework.boot.SpringApplicationRunListeners.started(SpringApplicationRunListeners.java:48)中的.boot.context.event.EventPublishingRunListener.started(EventPublishingRunListener.java:60)org.springframework.boot.SpringApplication.run(SpringApplication.java:302) )在org.springframework.boot.SpringApplication.run(SpringApplication.java:1185)at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174) at com.myshop.demo.Application.main(Application.java:26) com.myshop.demo.Application.main上的org.springframework.boot.SpringApplication.run(SpringApplication.java:1174)(Application.java:26)

It seems to me that the IDE cannot succesfully create the manifest.mf file (while instead the maven plugin do it perfectly) but i have no clue how to resolve this. 在我看来,IDE无法成功创建manifest.mf文件(而maven插件完美地完成它),但我不知道如何解决这个问题。

I've also tried to create myself the file pasting in my project pah: src/main/resources/META-INF/manifest.mf the one found in the jar, created with maven plugin. 我还尝试在我的项目pah中创建自己粘贴的文件:src / main / resources / META-INF / manifest.mf在jar中找到的文件,使用maven插件创建。

manifest.mf: MANIFEST.MF:

Manifest-Version: 1.0
Implementation-Title: demo
Implementation-Version: 0.0.1-SNAPSHOT
Archiver-Version: Plexus Archiver
Built-By: MyFirstName MySecondName
Start-Class: com.myshop.demo.Application
Implementation-Vendor-Id: com.myshop
Spring-Boot-Version: 1.3.6.RELEASE
Created-By: Apache Maven
Build-Jdk: 1.8.0_121
Implementation-Vendor: Pivotal Software, Inc.
Main-Class: org.springframework.boot.loader.JarLauncher

But the error didn't changed. 但错误没有改变。 Thank you for any help. 感谢您的任何帮助。

pom.xml: pom.xml中:

<?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.myshop</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.3.6.RELEASE</version>
</parent>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <!-- hot swapping, disable cache for template, enable live reload -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-rest</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
    </dependency>
    <!-- logging -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-log4j2</artifactId>
        </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <compilerVersion>1.8</compilerVersion> 
                    <archive>
                        <manifest>
                            <mainClass>com.myshop.demo</mainClass>
                        </manifest>
                    </archive>     
            </configuration>
        </plugin>
    </plugins>
</build>

Application.java: Application.java:

@SpringBootApplication
  public class Application {    
   public static void main(String[] args) {

    SpringApplication.run(Application.class, args);
  }
}

这是一个devtools启动异常,从pom.xml中删除该依赖,然后重新运行该应用程序。

The groovy-2.4.7.jar file was corrupted. groovy-2.4.7.jar文件已损坏。

Try to manually download the file from the internet and copy it to C:/Users/MyFirstName%20MySecondName/.m2/repository/org/codehaus/groovy/groovy/2.4.7/groovy-2.4.7.jar 尝试从Internet手动下载文件并将其复制到C:/Users/MyFirstName%20MySecondName/.m2/repository/org/codehaus/groovy/groovy/2.4.7/groovy-2.4.7.jar

It should work. 它应该工作。

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

相关问题 Spring-boot应用程序中的套接字写入错误 - Socket Write Error in a Spring-boot application 如何修复 spring-boot 应用程序中的错误“java.lang.NoClassDefFoundError: org/springframework/boot/bind/RelaxedPropertyResolver”? - How to fix the error 'java.lang.NoClassDefFoundError: org/springframework/boot/bind/RelaxedPropertyResolver' in a spring-boot application? java.lang.NoSuchMethodException 部署在 tomcat 上时 Spring-boot Web 应用程序中的错误 - java.lang.NoSuchMethodException error in Spring-boot web-application when deploying on tomcat 使用pom.xml和app.java的简单spring-boot应用程序显示构建失败错误 - Simple spring-boot application with pom.xml and app.java is showing build failed error 如何JUnit测试Spring-Boot的Application.java - How to JUnit Test Spring-Boot's Application.java 使用spring-boot运行java应用程序,并在digitalocean上运行gradle - Running a java application with spring-boot, and gradle on digitalocean 属性在基于Spring Boot的Java应用程序中不起作用 - Properties are not working in spring-boot based java application 如何使用 java 设置 spring-boot 应用程序 13 - How to set up a spring-boot application with java 13 如何将Java代理附加到正在运行的Spring Boot应用程序 - How to attach a java agent on to a running spring-boot application Java Standalone App中的Spring-boot application.yaml - Spring-boot application.yaml in Java Standalone App
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM