2

我尝试构建并运行 jhipster 注册表,但出现错误:

mvn package -Pprod

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

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

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

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

奇怪的是,当我执行

mvn clean package -Pprod

构建是好的,但它没有启动(同样的错误)。

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

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

谢谢,丹尼斯

4

3 回答 3

12

I found the solution. I added these dependencies in 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>

and all work. These dependencies were nevertheless obtained transitively, and I don't known why I have to add explicitly. Anybody has the response ?

Denis

于 2018-02-20T09:51:55.760 回答
5

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

于 2019-04-04T17:46:50.447 回答
-1

这样做是工作

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

@Atatorus

于 2019-06-21T15:20:39.823 回答