Maven Jetty插件:包装类型[jar]不支持

时间:2018-10-31 10:46:25

标签: maven spring-boot jetty embedded-jetty

我创建了一个带有SpringBoot的项目,项目包装类型为jar,并且我将码头依赖项添加到了项目中,当我尝试使用mvn jetty:run构建项目时,构建成功但我收到这样的消息

  

[INFO]跳过keycloak-springboot-demo:包装类型[jar]为   不支持

下面是我的pom.xml文件

<?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>

如何使用jetty:run命令在jetty服务器中运行项目?

3 个答案:

答案 0 :(得分:1)

我在9.4.19.v20190610上遇到了同样的问题。我必须添加:

<supportedPackagings>jar</supportedPackagings>

答案 1 :(得分:0)

jetty-maven-plugin将部署打包为war(网络存档)文件的Web应用。

您的项目被指定为<packaging>jar</packaging>,这意味着Jetty不知道如何部署它(什么是Web清单?描述符?libs?资源库?它在哪里扫描字节码以获取servlet注释和功能?等)< / p>

您的spring-boot用法似乎是基于spring-boot本身的独立嵌入式码头用法。在这种设置中使用jetty-maven-plugin是不合适的。

答案 2 :(得分:0)

尝试将Jetty版本更改为 9.3.27.v20190418

这对我有用

<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>

我尝试使用版本 9.4.X ,但没有效果