Maven Jetty plugin : packaging type [jar] is unsupported

北城以北 提交于 2020-01-23 19:38:29

问题


I have a created a project with SpringBoot and project packaging type is jar and also i added the jetty dependency into the project and when i am trying to build the project with mvn jetty:run ,build is successful but i am getting a message like this

[INFO] Skipping keycloak-springboot-demo : packaging type [jar] is unsupported

and below is my pom.xml file

<?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>dasniko</groupId>
    <artifactId>keycloak-springboot-demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>keycloak-springboot-demo</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.6.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <keycloak.version>3.2.0.Final</keycloak.version>
    </properties>

    <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-jetty</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.keycloak</groupId>
            <artifactId>keycloak-spring-boot-starter</artifactId>
            <version>${keycloak.version}</version>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.16.10</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>9.4.11.v20180605</version>
        </dependency>



    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>9.4.11.v20180605</version>
                <configuration>
                    <ignorePackaging>true</ignorePackaging>
                    </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

How to run the project in jetty server with jetty:run command ?


回答1:


I had the same problem for 9.4.19.v20190610. I had to add:

<supportedPackagings>jar</supportedPackagings>



回答2:


The jetty-maven-plugin will deploy webapps packaged as war (web archive) files.

Your project is specified as <packaging>jar</packaging> which means Jetty has no clue how to deploy it (what's the web manifest? descriptor? libs? resource base? where does it scan bytecode for servlet annotations and features? etc)

Your spring-boot usage seems to be based on standalone embedded-jetty usage within spring-boot itself. Using jetty-maven-plugin in this kind of setup is not appropriate.




回答3:


Try changing Jetty version to 9.3.27.v20190418

This work for me

<plugin>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <version>9.3.27.v20190418</version>
    <configuration>
      <httpConnector>
        <port>8080</port>
      </httpConnector>
      <scanIntervalSeconds>-1</scanIntervalSeconds>
      <reload>manual</reload>
      <useTestScope>true</useTestScope>
      <webAppConfig>
        <resourceBase>src/test/webjar-debug/META-INF/resources</resourceBase>
        <resourceBase>${project.basedir}/src/main/resources/META-INF/resources</resourceBase>
      </webAppConfig>
    </configuration>
</plugin>

I tried with versions 9.4.X but none works



来源:https://stackoverflow.com/questions/53081537/maven-jetty-plugin-packaging-type-jar-is-unsupported

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!