JHipster注册表:构建错误

Ata*_*rus 2 jhipster-registry

我尝试构建并运行jhipster注册表,但是我收到一个错误:

mvn package -Pprod
Run Code Online (Sandbox Code Playgroud)

我在测试中遇到以下错误:

Tests in error: 
  SwaggerBasePathRewritingFilterTest.<init>:20 »  Unresolved compilation problem...
  SwaggerBasePathRewritingFilterTest.<init>:20 »  Unresolved compilation problem...
  SwaggerBasePathRewritingFilterTest.<init>:20 »  Unresolved compilation problem...
  SwaggerBasePathRewritingFilterTest.<init>:20 »  Unresolved compilation problem...
  AccountResourceTest.setup:33 » NoClassDefFound HttpServletRequest
  AccountResourceTest.setup:33 » NoClassDefFound HttpServletRequest
  AccountResourceTest.setup:33 » NoClassDefFound HttpServletRequest
  AccountResourceTest.setup:33 » NoClassDefFound HttpServletRequest
  UserJWTControllerTest.setup:39 » NoClassDefFound HttpServletResponse
  UserJWTControllerTest.setup:39 » NoClassDefFound HttpServletResponse
  UserJWTControllerTest.setup:39 » NoClassDefFound HttpServletResponse
  ExceptionTranslatorTest.setup:37 » NoClassDefFound HttpServletRequest
  ExceptionTranslatorTest.setup:37 » NoClassDefFound HttpServletRequest
  ExceptionTranslatorTest.setup:37 » NoClassDefFound HttpServletRequest
  ExceptionTranslatorTest.setup:37 » NoClassDefFound HttpServletRequest
  ExceptionTranslatorTest.setup:37 » NoClassDefFound HttpServletRequest
Run Code Online (Sandbox Code Playgroud)

如果我跳过测试,构建就可以了,但是当我启动时遇到了同样的错误:

./mvnw -Pdev

2018-02-16 17:52:22.011  WARN 5354 --- [  restartedMain] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'undertowEmbeddedServletContainerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfiguration$EmbeddedUndertow.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'webConfigurer' defined in file [/home/denis/ngworkspace/jhipster-registry/target/classes/io/github/jhipster/registry/config/WebConfigurer.class]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.github.jhipster.registry.config.WebConfigurer$$EnhancerBySpringCGLIB$$a8d0938a]: Constructor threw exception; nested exception is java.lang.Error: Unresolved compilation problems: 
        The import io.undertow.UndertowOptions cannot be resolved
        ServletContext cannot be resolved to a type
        ServletException cannot be resolved to a type
        DispatcherType cannot be resolved to a type
        DispatcherType cannot be resolved to a variable
        DispatcherType cannot be resolved to a variable
        DispatcherType cannot be resolved to a variable
        The type io.undertow.Undertow$Builder cannot be resolved. It is indirectly referenced from required .class files
        This lambda expression refers to the missing type Undertow$Builder
        UndertowOptions cannot be resolved to a variable
        ServletContext cannot be resolved to a type
        DispatcherType cannot be resolved to a type
        FilterRegistration cannot be resolved to a type
        ServletContext cannot be resolved to a type
        DispatcherType cannot be resolved to a type
        FilterRegistration cannot be resolved to a type
        ServletRegistration cannot be resolved to a type

2018-02-16 17:52:22.032 ERROR 5354 --- [  restartedMain] o.s.boot.SpringApplication               : Application startup failed

org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'undertowEmbeddedServletContainerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfiguration$EmbeddedUndertow.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'webConfigurer' defined in file [/home/denis/ngworkspace/jhipster-registry/target/classes/io/github/jhipster/registry/config/WebConfigurer.class]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.github.jhipster.registry.config.WebConfigurer$$EnhancerBySpringCGLIB$$a8d0938a]: Constructor threw exception; nested exception is java.lang.Error: Unresolved compilation problems: 
        The import io.undertow.UndertowOptions cannot be resolved
        ServletContext cannot be resolved to a type
        ServletException cannot be resolved to a type
...
Run Code Online (Sandbox Code Playgroud)

奇怪的是,当我执行时

mvn clean package -Pprod
Run Code Online (Sandbox Code Playgroud)

构建没问题,但它没有启动(相同的错误).

我在Linux上使用从github克隆的3.2.4版中的注册表.

如何构建注册表没有错误?我忘了什么吗?

谢谢,丹尼斯

Ata*_*rus 12

我找到了解决方案.我在pom.xml中添加了这些依赖项:

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-undertow</artifactId>
        <scope>provided</scope>
    </dependency>
Run Code Online (Sandbox Code Playgroud)

和所有的工作.然而,这些依赖关系是传递性的,我不知道为什么我必须明确添加.有人有回应吗?

丹尼斯

  • 我认为Eclipse中的Maven插件存在问题,因为我在intellij想法中运行了相同的项目,但效果很好,但是当我在Eclipse中导入相同的项目时,wowing错误导入io.undertow.UndertowOptions。 (2认同)

Yur*_*din 5

如果您使用 Eclipse 运行:在 Eclipse 中选择 Project Properties->Maven->Active Maven Profiles(逗号分隔),并将其设置为 dev 这将触发项目的 Maven 更新,并且所有内容都会编译 无需将依赖项放入 pom 中