将应用程序作为jar运行时会给出fileNotFoundException

时间:2020-04-02 10:32:22

标签: spring spring-boot groovy spring-websocket

我试图将我的spring应用程序作为jar运行,但出现以下错误

java.io.FileNotFoundException: class path resource [org/springframework/web/socket/config/annotation/AbstractWebSocketMessageBrokerConfigurer.class] cannot be opened because it does not exist

它可以从intelij正常运行(因为在我的主类中可以使用播放按钮运行)。我在项目结构->库和外部库下找到该文件(尽管已解压缩) 香港专业教育学院试图研究它,但到处(下面的示例列表)似乎都在谈论xml文件而不是类

Spring ClassPathResource - cannot be opened because it does not exist

Class path resource cannot be opened because it does not exist

How to avoid "class path resource [...] cannot be opened because it does not exist" in a spring boot application?

java.io.FileNotFoundException: class path resource can't be opened

java.io.FileNotFoundException: class path resource cannot be opened because it does not exist

我的gradle文件:

plugins {
    id 'org.springframework.boot' version '2.2.4.RELEASE'
    id 'io.spring.dependency-management' version '1.0.9.RELEASE'
    id 'war'
    id 'groovy'
//    id 'java'
}
war {
    enabled = true
}
jar {
    manifest {
        attributes 'Main-Class': 'co.za.ebucks.HandlingRewardsFormSubmission'
    }
}

group = 'co.za.ebucks'
version = '1.0.0'
sourceCompatibility = '1.8'

repositories {
    mavenCentral()
}
ext {
    seleniumVersion = '3.141.59'
}
configurations {
    developmentOnly
    runtimeClasspath {
        extendsFrom developmentOnly
    }
}
test {
    useTestNG()
}

dependencies {

    implementation 'org.springframework.boot:spring-boot-starter-tomcat'
    implementation 'org.springframework.boot:spring-boot-starter-actuator'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-webflux'
//    implementation 'org.springframework.session:spring-session-core'
    implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
    implementation 'org.springframework.boot:spring-boot-starter-integration'
    implementation 'org.springframework.boot:spring-boot-starter-websocket'
    implementation 'org.springframework:spring-messaging'
    implementation 'org.springframework.integration:spring-integration-file'

    implementation group: 'org.webjars.bower', name: 'angular-ui-router', version: '0.2.8'
    implementation group: 'org.webjars', name:'angularjs', version: '1.3.0-beta.11'
    implementation group: 'org.webjars', name: 'bootstrap', version: '3.1.1-1'

//    implementation 'org.webjars.bower:angular-ui-router'//, version: '1.0.20'

    implementation 'commons-io:commons-io'//, version: '2.4'
    implementation 'org.apache.commons:commons-dbcp2'//, version: '2.7.0'
    implementation 'org.hibernate.validator:hibernate-validator'//, version: '6.1.2.Final'
//    implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect'//, version: '2.4.1'
    implementation 'javax.servlet:javax.servlet-api'//, version: '4.0.1'
//    compile group: 'org.apache.tomcat', name: 'tomcat-jni', version: '9.0.33'

    implementation group: 'de.codecentric', name: 'spring-boot-admin-starter-client', version: '2.2.2'
    implementation group: 'de.codecentric', name: 'spring-boot-admin-server', version: '2.2.2'
    implementation group: 'org.testng', name: 'testng', version: '7.1.0'
    implementation group: 'org.codehaus.groovy', name: 'groovy-all', version: '3.0.0'
    implementation group: 'com.google.inject', name: 'guice', version: '4.2.2'
    implementation group: 'com.google.guava', name: 'guava', version: '28.1-jre'
    implementation group: 'cglib', name: 'cglib', version: '3.3.0'
    implementation group: 'org.postgresql', name: 'postgresql', version: '42.2.10'

    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
    testImplementation 'io.projectreactor:reactor-test'
    implementation "org.seleniumhq.selenium:selenium-support:${seleniumVersion}"
    implementation group: 'io.appium', name: 'java-client', version: '7.3.0'
    implementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: "${seleniumVersion}"
    implementation group: 'org.seleniumhq.selenium', name: 'selenium-server', version: "${seleniumVersion}"
    implementation group: 'org.seleniumhq.selenium', name: 'selenium-chrome-driver', version: "${seleniumVersion}"

    testImplementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.13.0'
    testImplementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.13.0'
    testImplementation group: 'org.testng', name: 'testng', version: '7.1.0'

    developmentOnly 'org.springframework.boot:spring-boot-devtools'
}

我确定所讨论的课程是

import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry
import org.springframework.web.socket.server.support.DefaultHandshakeHandler;

@Configuration
@EnableWebSocketMessageBroker
class WebSocketDefaultConfig extends AbstractWebSocketMessageBrokerConfigurer {

    @Override
    void configureMessageBroker(MessageBrokerRegistry config) {
//        config.enableStompBrokerRelay("/topic/", "/queue/");
        config.enableSimpleBroker("/topic/", "/queue/");
        config.setApplicationDestinationPrefixes("/app");
    }

    @Override
    void registerStompEndpoints(StompEndpointRegistry registry) {
        registry.addEndpoint("/tailfilesep")
//                .setAllowedOrigins("*")
//                .setHandshakeHandler(new DefaultHandshakeHandler())
                .withSockJS()
    }
}

请帮助我,这已经使我沮丧。为什么那个课不在罐子里?

1 个答案:

答案 0 :(得分:0)

唯一有效的方法是创建一个新项目-复制并粘贴所有代码,构建文件,一切……大声笑并且很好。

Intelij腐败在某处