zoukankan      html  css  js  c++  java
  • java报错:A child container failed during start和dependency的scope取值范围

    A child container failed during start,我遇到的原因是引用javax.servlet-api的时候没有加scope

    <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>4.0.1</version>
    <scope>provided</scope>
    </dependency>

    scope的取值和含义:

    compile:默认的scope,表示 dependency 都可以在生命周期中使用。而且,这些dependencies 会传递到依赖的项目中。
    provided:跟compile相似,但是表明了dependency 由JDK或者容器提供,例如Servlet AP和一些Java EE APIs。这个scope 只能作用在编译和测试时,同时没有传递性。使用这个时,不会将包打入本项目中,只是依赖过来。
    使用默认或其他时,会将依赖的项目打成jar包,放入本项目的Lib里。
    runtime:表示dependency不作用在编译时,但会作用在运行和测试时
    test:表示dependency作用在测试时,不作用在运行时。
    system:跟provided 相似,但是在系统中要以外部JAR包的形式提供,maven不会在repository查找它。 例如:
    <dependencies>
      <dependency>
       <groupId>javax.sql</groupId>
       <artifactId>jdbc-stdext</artifactId>
       <version>2.0</version>
       <scope>system</scope>
       <systemPath>${java.home}/lib/rt.jar</systemPath>
      </dependency>
    </dependencies>
    import: (Maven 2.0.9 之后新增)它只使用在<dependencyManagement>中,表示从其它的pom中导入dependency的配置,例如:
    <dependency>
    <groupId>maven</groupId>
    <artifactId>项目A</artifactId>
    <version>1.0</version>
    <type>pom</type>
    <scope>import</scope>
    </dependency>

  • 相关阅读:
    RfcDestinationManager.UnregisterDestinationConfiguration时报错cannot unregister the given destination configuration
    SVN文件自动加锁-Win7
    linux 命令详解 sort
    Tensorflow的采样方法:candidate sampling(zhuan)
    (转载)机器学习中的目标函数、损失函数、代价函数有什么区别
    tensorflow dropout
    textcnn
    tensorflow学习笔记(三十九):双向rnn
    sklearn one_hot 操作
    sklearn 划分数据集。
  • 原文地址:https://www.cnblogs.com/xsj1989/p/15097911.html
Copyright © 2011-2022 走看看