Maven - scope 說明

provided

參與編譯,不參與打包

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

system

參與編譯,不參與打包。需要指定參與打包
    <dependency>
        <groupId>aspose</groupId>
        <artifactId>aspose-cells</artifactId>
        <version>${aspose-cells.version}</version>
        <systemPath>${pom.basedir}/../../asserts/lib/aspose-cells-8.5.2.jar</systemPath>
        <scope>system</scope>
     </dependency>
	 //指定參與打包
          <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${spring-boot.version}</version>
                <configuration>
                    <finalName>${project.build.finalName}</finalName>
                    <includeSystemScope>true</includeSystemScope>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

test

測試使用:參與編譯,不參與打包

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

runtime

開發使用,不參與編譯,參與打包

   <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <scope>runtime</scope>
    </dependency>
compile
參與編譯,參與打包。默認值
     <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
    </dependency>

optional

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章