一、引用本地包web
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_core</artifactId>
<version>2.10</version>
<scope>system</scope>
<systemPath>E:\Official Projects\Jmeter\apache-jmeter-2.10\lib\ext\ApacheJMeter_core.jar</systemPath>
</dependency>spring
</scope>能夠使用如下值:apache
* compile,缺省值,適用於全部階段,會隨着項目一塊兒發佈。
* provided,相似compile,指望JDK、容器或使用者會提供這個依賴。如servlet.jar。
* runtime,只在運行時使用,如JDBC驅動,適用運行和測試階段。
* test,只在測試時使用,用於編譯和運行測試代碼。不會隨項目發佈。
* system,相似provided,須要顯式提供包含依賴的jar,Maven不會在Repository中查找它。app
二、jar打包工具,maven-shade-plugin,將依賴包一塊兒打包(它可以將全部jar裏的spring.schemas文件進行合併,在最終生成的單一jar包裏)eclipse
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.handlers</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>maven
三、將配置文件打在jar包以外ide
<build>工具
<plugins>測試
<plugin>ui
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath><!-- 加載class -->
<classpathPrefix>lib/</classpathPrefix><!-- 加載的class目錄的前綴(依賴的jar目錄) -->
<mainClass>com.bj.ihanysoft.MavenDemo.App</mainClass><!-- 入口類名 -->
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
<!-- 以utf-8編碼拷貝配置文件,拷貝過程當中是能夠作變量替換的,也就是說你的配置文件能夠是個模板,裏面的${}所包含的內容是能夠拷貝過程當中替換的 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<encoding>UTF-8</encoding>
<outputDirectory>${project.build.directory}</outputDirectory><!-- 把配置文件拷到和jar包同一個路徑下 -->
<resources>
<resource>
<directory>src/main/resource/</directory>
<includes>
<include>s.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<!-- 打jar包時須要把配置文件給排除在外 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>lib</classifier>
<excludes>
<exclude>s.xml</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>