복붙노트

[SPRING] 바람둥이가없는 스프링 부트 전쟁

SPRING

바람둥이가없는 스프링 부트 전쟁

난 maven과 함께 포함 된 바람둥이없이 전쟁 파일을 만들고 싶다. 여기에 내 pom의 관련 부분

...
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.1.6.RELEASE</version>
</parent>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <!-- Add tomcat only if I want to run directly -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>
...

내가 mvn 꾸러미를 실행했다면 어떻게하면 tomcat * .jar가 lib 디렉토리에 있지만 lib-folder 안에있는 war 파일을 얻을 수 있습니다. 나는 build-tool-plugins-maven-packaging을 읽었지만 잘못된 것을 발견하지 못했다.

주된 아이디어는 응용 프로그램으로 실행하는 것입니다. 고객이 응용 프로그램 서버에 응용 프로그램을 배포하는 방법을 알고 싶습니다.

해결법

  1. ==============================

    1.M. Deinum의 힌트에 따라 나는 바람둥이 의존성을 배제했다.

    M. Deinum의 힌트에 따라 나는 바람둥이 의존성을 배제했다.

    다음 pom.xml (관련 스 니펫)을 사용하면 maven 클린 패키지에는 얻을 수없는 결과가 있습니다.

    ...
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.1.6.RELEASE</version>
    </parent>
    <dependencies>
        <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>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <!-- Add tomcat only if I want to run directly -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
    ...
    

    아이디어 사용자에 대한 경고 : 실행 구성에서 "제공된 범위와의 종속성 포함"을 활성화해야합니다 (자세한 내용은 IntelliJ Idea에서 봄 부팅 응용 프로그램을 시작할 수 없음 참조)

  2. ==============================

    2.스프링 부트 방식인지는 확실치 않지만 maven-war-plugin 설정을 사용하여 tomcat 항아리를 제외 할 수 있습니다. 즉, 다음을 pom.xml에 추가하십시오.

    스프링 부트 방식인지는 확실치 않지만 maven-war-plugin 설정을 사용하여 tomcat 항아리를 제외 할 수 있습니다. 즉, 다음을 pom.xml에 추가하십시오.

    <build>
        <plugins>
            ...
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <packagingExcludes>WEB-INF/lib/tomcat-*.jar</packagingExcludes>
                </configuration>
            </plugin>
        </plugins>
    </build>
    

    이 방법을 사용하면 생성 된 war는 실행 가능하지 않으며 (java -jar를 사용하여 명령 줄에서 실행할 수 없음) 모든 서블릿 컨테이너에만 배포 할 수 있습니다

  3. ==============================

    3.나는이 같은 필요성을 가지고 있지만 언급 된 의존성을 제거하는 것은 효과가 없었다. 내 pom 파일에이 war 종속성을 추가하여 WAR 파일을 가져올 수있었습니다.

    나는이 같은 필요성을 가지고 있지만 언급 된 의존성을 제거하는 것은 효과가 없었다. 내 pom 파일에이 war 종속성을 추가하여 WAR 파일을 가져올 수있었습니다.

    이 Spring 문서를 가이드로 사용하여 공유하면 다른 사람들에게도 도움이 될 것입니다.

  4. ==============================

    4.스프링 부트 스타터 종속성 변경

    스프링 부트 스타터 종속성 변경

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

    여기에는 내장 된 Tomcat 서버가 제외됩니다.

       <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    
  5. from https://stackoverflow.com/questions/25991789/spring-boot-war-without-tomcat-embedded by cc-by-sa and MIT license