programing

mvn spring-boot: 실행이 스프링을 시작하지 않음

stoneblock 2023. 3. 10. 21:02

mvn spring-boot: 실행이 스프링을 시작하지 않음

답변: 버전 태그를 0.0.1-SNAPSHOT에서 1.0.2로 변경했습니다.RELEASE로 동작했습니다.아래의 답변을 참조해 주세요.

매뉴얼에 따라 지시에 따라 Example.java를 작성했습니다.내가 달릴 때mvn spring-boot:run봄은 단지 BUILD SUCCESS라고 시작하는 것이 아닙니다.Spring이 시작되고 Tomcat이 페이지를 제공하는 것으로 알고 있습니다.

E:\workspace\SpringBoot>mvn spring-boot:run
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building myproject 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:1.1.0.BUILD-SNAPSHOT:run (default-cli) @ myproject >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ myproject ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\workspace\SpringBoot\src\main\resources
[INFO] skip non existing resourceDirectory E:\workspace\SpringBoot\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ myproject ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ myproject ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\workspace\SpringBoot\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ myproject ---
[INFO] No sources to compile
[INFO]
[INFO] <<< spring-boot-maven-plugin:1.1.0.BUILD-SNAPSHOT:run (default-cli) @ myproject <<<
[INFO]
[INFO] --- spring-boot-maven-plugin:1.1.0.BUILD-SNAPSHOT:run (default-cli) @ myproject ---
[INFO] Attaching agents: []
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.108 s
[INFO] Finished at: 2014-05-01T14:54:26-05:00
[INFO] Final Memory: 16M/232M
[INFO] ------------------------------------------------------------------------

자세한 내용은 다음과 같습니다.

E:\workspace\SpringBoot>java -version
java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)

E:\workspace\SpringBoot>mvn -v
Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T12:37:52-05:00)
Maven home: E:\apps\apache-maven-3.2.1\bin\..
Java version: 1.7.0_21, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_21\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"

example.java는 E:\workspace\SpringBoot\src\main\java에 있습니다.

import org.springframework.boot.*;
import org.springframework.boot.autoconfigure.*;
import org.springframework.stereotype.*;
import org.springframework.web.bind.annotation.*;

@RestController
@EnableAutoConfiguration
public class Example {

    @RequestMapping("/")
    String home() {
        return "Hello World!";
    }

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

}

pom.xml은 E:\workspace\SpringBoot에 있습니다.

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

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.1.0.BUILD-SNAPSHOT</version>
    </parent>

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

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>

    <!-- (you don't need this if you are using a .RELEASE version) -->
    <repositories>
        <repository>
            <id>spring-snapshots</id>
            <url>http://repo.spring.io/snapshot</url>
            <snapshots><enabled>true</enabled></snapshots>
        </repository>
        <repository>
            <id>spring-milestones</id>
            <url>http://repo.spring.io/milestone</url>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>spring-snapshots</id>
            <url>http://repo.spring.io/snapshot</url>
        </pluginRepository>
        <pluginRepository>
            <id>spring-milestones</id>
            <url>http://repo.spring.io/milestone</url>
        </pluginRepository>
    </pluginRepositories>

</project>

spring-boot 1.0.2로 시험해 보세요.풀어주다.1.1.0 스냅샷에서 "실행" mojo가 변경되어 Windows 고유의 문제가 발생했을 수 있습니다(앱은 실행 중이지만 콘솔 출력은 표시되지 않습니다).

업데이트: 이 버그는 수정되었습니다.따라서 1.1.0에서도 동작합니다.

폼에 Spring Boot Maven 플러그인이 없습니다.

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

버전 태그를 0.0.1-SNAPSHOT에서 1.0.2로 변경했습니다.릴리즈와 성공:

<?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.example</groupId>
    <artifactId>myproject</artifactId>
    <version>1.0.2.RELEASE</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.1.0.BUILD-SNAPSHOT</version>
    </parent>

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

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>

    <!-- (you don't need this if you are using a .RELEASE version) -->
    <repositories>
        <repository>
            <id>spring-snapshots</id>
            <url>http://repo.spring.io/snapshot</url>
            <snapshots><enabled>true</enabled></snapshots>
        </repository>
        <repository>
            <id>spring-milestones</id>
            <url>http://repo.spring.io/milestone</url>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>spring-snapshots</id>
            <url>http://repo.spring.io/snapshot</url>
        </pluginRepository>
        <pluginRepository>
            <id>spring-milestones</id>
            <url>http://repo.spring.io/milestone</url>
        </pluginRepository>
    </pluginRepositories>

</project>

봄이 시작되었습니다.

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::  (v1.1.0.BUILD-SNAPSHOT)

최신 버전으로 이동하여 스타터 생성기 페이지에서 종속성으로 mvc를 선택했습니다(이것에 질린 후).모든 것이 순조롭게 진행되었다.

maven multi-project에서 여러 pom.xml을 리팩터링하다가 비슷한 문제가 발생하였습니다.문제는 'mvn clean install' Spring이 시작되지 않았을 때 시작되었지만, 그는 이전에 실행했습니다.이 문제는 maven-surefire-plugin 속성 섹션을 루트 모듈에서 도메인 모듈로 이동하자 사라졌습니다.그러다 이 의존성이 중복된다는 걸 알게 됐고 그녀를 제거했어요이 수정은 이상해 보이지만 도움이 되었다.

언급URL : https://stackoverflow.com/questions/23414609/mvn-spring-bootrun-doesnt-start-spring