有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

JAVAspring启动和maven构建时lang.ClassNotFoundException

我在eclipse上使用SpringBoot和maven,并在eclipse上构建maven。当我尝试运行jar文件时,出现了错误

我在manifast中添加了mainclass,在pom中添加了spring引导插件。xml,以及清理和重建maven。我有BacnetMonitoring系统应用程序。位于src/main/java/com的java文件。bacnet。监控文件夹。我已经在类上注释了@SpringBootApplication,我的lib文件夹中有一些jar文件要编译

<?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>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.4.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.bacnet.monitoring</groupId>
    <artifactId>BACnetMonitoringSystem</artifactId>
    <version>1.1.3</version>
    <packaging>jar</packaging>
    <name>BACnetMonitoringSystem</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <!-- dependency -->
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.0.3.RELEASE</version>
                <configuration>
                    <mainClass>com.bacnet.monitoring.BaCnetMonitoringSystemApplication</mainClass>
                    <includeSystemScope>true</includeSystemScope>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>com.bacnet.monitoring.BaCnetMonitoringSystemApplication</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>

        </plugins>

    </build>

</project>

java-jar BACnetMonitoringSystem-1.1.3-jar-with-dependencies。罐子 오류: 기본 클래스 通用域名格式。bacnet。监测。BacnetMonitoring系统应用程序을(를) 찾거나 로드할 수 없습니다. (这意味着无法找到或加载基本类BaCnetMonitoringSystemApplication)

原因:java。lang.ClassNotFoundException:com。bacnet。监测。BacnetMonitoring系统应用程序


共 (1) 个答案

  1. # 1 楼答案

    您可以尝试几种解决方案:

    1. 添加到pom中。xml

      <properties> <start-class>com.bacnet.monitoring.BaCnetMonitoringSystemApplication</start-class> </properties>

    2. 尝试在Eclipse中更新项目:右键单击项目->;Maven->;更新项目。然后重新运行项目

    3. 清理maven缓存并重新运行:mvn dependency:purge-local-repository