programing

스프링 부트 메이븐 플러그인 클래스를 찾을 수 없습니다.

magicmemo 2023. 2. 25. 20:51
반응형

스프링 부트 메이븐 플러그인 클래스를 찾을 수 없습니다.

저는 3개의 메이븐 프로젝트가 있습니다. 하나는 폼 패키지이고 다른 하나는 항아리 포장입니다.여기서는 관리자용 폼입니다.

<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.sounds.bvs</groupId>
    <artifactId>admin-aggregator</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>


    <modules>
        <module>../admin-lib</module>
        <module>../admin-rest</module>
    </modules>


    <properties>
        <project.build.SourceEncoding>UTF-8</project.build.SourceEncoding>
        <spring-boot-version>2.0.4.RELEASE</spring-boot-version>
        <spring-version>2.0.4.RELEASE</spring-version>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
        <start-class>com.sounds.bvs.AdminRestApp</start-class>
    </properties>

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

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.sounds.bvs</groupId>
                <artifactId>admin-lib</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>com.sounds.bvs</groupId>
                <artifactId>admin-rest</artifactId>
                <version>${project.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                        <configuration>
                            <classifier>exec</classifier>
                            <mainClass>${start-class}</mainClass>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven.compiler.plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <showDeprication>true</showDeprication>
                    <showWarnings>true</showWarnings>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>https://repo.spring.io/snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>https://repo.spring.io/snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
        <pluginRepository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>

</project>

또한 admin-rest pom.xml과 그 Main class는 ctrl-click으로 각 프로젝트로 이동하고 type search는 admin-rest 프로젝트의 메인클래스를 찾을 수 있기 때문에 찾을 수 없습니다.+T도 정지하고 있습니다.

<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>com.sounds.bvs</groupId>
        <artifactId>admin-aggregator</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <artifactId>admin-rest</artifactId>

    <dependencies>
        <dependency>
            <groupId>com.sounds.bvs</groupId>
            <artifactId>admin-lib</artifactId>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-jetty -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jetty</artifactId>
        </dependency>


    </dependencies>
</project>

메인 클래스 AdminRestApp.java와 함께 관리자 어그리게이터를 실행하려고 합니다.

mvn clean spring-boot:run
mvnw.cmd clean spring-boot:run
./mvnw spring-boot:run 

하지만 아무도 작동하지 않는다.

package com.sounds.bvs;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class AdminRestApp {

    public static void main(String[] args) {
        SpringApplication.run(AdminRestApp.class, args);
    }
}



and the exception i see class not found exception i tried all which were from similar topic none helped, the start-class tag is also place and hard code the full path com.sounds.bvs.AdminRestApp in mainClass still that also did not help,

spring boot version과 maven compiler plugin version을 변경해 보았습니다.dint도 도움이 되었습니다.

이전에 패키지 경로는 large com이었습니다.sounds.bvs.admin.rest도 같은 문제로 인해 패키지 이름이 변경되었습니다.

부족한 부분을 미리 알려주시면 감사하겠습니다.

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] `enter code here`
[INFO] admin-aggregator
[INFO] admin-lib
[INFO] admin-rest
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building admin-aggregator 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) @ admin-aggregator ---
[INFO] 
[INFO] >>> spring-boot-maven-plugin:2.0.4.RELEASE:run (default-cli) > test-compile @ admin-aggregator >>>
[INFO] 
[INFO] <<< spring-boot-maven-plugin:2.0.4.RELEASE:run (default-cli) < test-compile @ admin-aggregator <<<
[INFO] 
[INFO] --- spring-boot-maven-plugin:2.0.4.RELEASE:run (default-cli) @ admin-aggregator ---
[WARNING] 
java.lang.ClassNotFoundException: com.sounds.bvs.AdminRestApp
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run(AbstractRunMojo.java:491)
    at java.lang.Thread.run(Thread.java:745)
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] admin-aggregator ................................... FAILURE [ 42.358 s]
[INFO] admin-lib .......................................... SKIPPED
[INFO] admin-rest ......................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 56.280 s
[INFO] Finished at: 2018-08-10T00:43:37+05:30
[INFO] Final Memory: 17M/111M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.0.4.RELEASE:run (default-cli) on project admin-aggregator: An exception occurred while running. com.sounds.bvs.AdminRestApp -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

스프링 부트 버전을 추가하면 문제가 해결되었습니다.

    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>2.4.1</version>
        </plugin>
    </plugins>

Maven 탭에서 사용 중인 버전의 스프링 부트로 대체합니다. -> 플러그인

그것은 나에게 효과가 있었다.

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

pom.xml 의존성에 ${project.parent.version}을 추가하면 문제가 해결되었습니다.

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-maven-plugin</artifactId>
  <version>${project.parent.version}</version>
  <type>maven-plugin</type>
</dependency>

버전만 추가합니다.

<groupId>org.springframework.boot</groupId> 
<artifactId>spring-boot-maven-plugin</artifactId> 
<version>${project.parent.version}</version> 

예외 오류

여기 https://docs.spring.io/spring-android/docs/2.0.0.M3/reference/html/maven.html에서 읽었어요.https://search.maven.org/ 링크에 접속하여 검색어에 spring-boot-maven-mapen-http://frecision을 입력합니다.

그리고 나의 의존을 얻습니다.그리고 나한테도 효과가 있었어

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-maven-plugin</artifactId>
  <version>2.3.4.RELEASE</version>
  <type>maven-plugin</type>
</dependency>

이 명령어를 실행할 필요가 있습니다.mvn spring-boot:runSpring Boot 응용 프로그램을 포함하는 모듈 메이븐으로부터의 명령어(admin-rest), 부모 모듈 ( )admin-aggregator).
단, 부모 모듈에서 실행합니다.

.m2 폴더를 삭제하고 pom.xml 파일을 다시 설치했더니 문제가 해결되었습니다.

다음과 같이 Spring Boot 버전을 추가해야 합니다.

<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>version</version>

언급URL : https://stackoverflow.com/questions/51774552/spring-boot-maven-plugin-class-not-found

반응형