導航:首頁 > 文件管理 > javamaven配置文件

javamaven配置文件

發布時間:2023-07-29 01:38:53

java maven創建web把Spring放在src/main/讀取不到配置文件是怎麼回事

classpath:是從類路徑里查找配置文件,也就是/WEB-INF/classes目錄下找SpringMVC-servlet.xml。

你寫了classpath了,不會從web-info下找,而是去web-inf/classes下面找,所以找不到。

Ⅱ maven把java項目打包,如何把配置文件提出來

每個項目的pom.xml就是maven配置文件。復制出來...

Ⅲ Java Maven打包總結(Jenkins多模塊編譯部署)

原文地址: Java Maven打包總結(Jenkins多模塊編譯部署)

依次執行了clean、resources、compile、testResources、testCompile、test、jar(打包)等7個階段。
完成了項目編譯、單元測試、打包功能,但沒有把打好的可執行jar包(war包或其它形式的包)布署到本地maven倉庫和遠程maven私服倉庫

依次執行了clean、resources、compile、testResources、testCompile、test、jar(打包)、install等8個階段。
完成了項目編譯、單元測試、打包功能,同時把打好的可執行jar包(war包或其它形式的包)布署到本地maven倉庫,但沒有布署到遠程maven私服倉庫

依次執行了clean、resources、compile、testResources、testCompile、test、jar(打包)、install、deploy等9個階段。完成了項目編譯、單元測試、打包功能,同時把打好的可執行jar包(war包或其它形式的包)布署到本地maven倉庫和遠程maven私服倉庫

可以看到主要區別在把生成的jar包最終存放的位置, package只管打包; install把打好的包放到了本地maven倉庫;deploy是同時放到本地倉庫和遠程maven私服

這里本地倉庫默認是 /root/.m2/repository/ ,具體配置在 ${M2_HOME}/conf/settings 的 localRepository 配置項決定。遠程私服倉庫一般是nexus,具體地址在項目的pom.xml中配置。比如

一般是進入父級目錄之後執行

如果是多級目錄的話,有時候並不一定是按照 具體的項目來 編譯,比如

這個時候如果一個項目一個項目來編譯會超級多,很繁瑣,這里是按照 subparentproject 來編譯,命令如下

有個注意的地方:
subparentproject 目錄下的pom.xml文件中一定有類型如下的配置

1、需要安裝插件 Extended Choice Parameter Plug-In 可以支持參數單選、多選
2、項目選擇"自由風格",而不是maven編譯
3、在「構建」 -> "執行shell" 中編寫 子模塊編譯腳本及其後續處理

具體配置如下圖

「構建」 -> "執行shell" 中的處理腳本

附加:

Linux Bash下字元串操作總結

Ⅳ maven把java項目打包,如何把配置文件提出來

你好:這個把配置文件提取出來可以再pm.xml裡面配置java項目文件路徑下文件打包方式來實現。舉例如下,參考下。

<?xmlversion="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.tmtpt</groupId>
<artifactId>tmrpt</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>

<artifactId>tmrpt-client</artifactId>
<version>2.2.2</version>
<name>vpetl-client</name>
<url>www.tmrpt.com</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.sun.jna</groupId>
<artifactId>jna</artifactId>
<version>4.0.0</version>
</dependency>
</dependencies>
<build>
<finalName>tmrpt-client</finalName>
<defaultGoal>install</defaultGoal>
<plugins>
<!--<plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version><configuration><source>1.6</source><target>1.6</target>
<encoding>UTF-8</encoding></configuration></plugin>-->

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.vprisk.main.EtlClientStart</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classesDirectory>${basedir}/target/classes</classesDirectory>
<finalName>${project.artifactId}-${project.version}</finalName>
<outputDirectory>${basedir}/target/maven-archiver</outputDirectory>
<excludes>
<exclude>*.conf</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
<!--拷貝依賴的jar包到lib目錄-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>-dependencies</id>
<phase>package</phase>
<goals>
<goal>-dependencies</goal>
</goals>
<configuration>
<outputDirectory>
${project.build.directory}/maven-archiver/lib
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>-resources</id>
<phase>package</phase>
<goals>
<goal>-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/maven-archiver/resources</outputDirectory>
<resources>
<resource>
<directory>${basedir}/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<!--<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<encoding>UTF-8</encoding>
<appendAssemblyId>true</appendAssemblyId>
<descriptors>
<descriptor>${basedir}/src/assembly.xml</descriptor>
</descriptors>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix/>
<mainClass>com.vprisk.main.EtlserverStart</mainClass>
</manifest>

<manifestEntries>
<Class-Path>.</Class-Path>
</manifestEntries>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>bindtothepackagingphase
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>-->
</plugins>
</build>
</project>

Ⅳ Maven-Spring多項目載入配置文件

1,classpath:applicationContext.xml改為classpath*:applicationContext.xml
這么寫也是一樣的效果:classpath*:/applicationContext.xml
2,在applicationContext.xml引用其它的配置文件:
如果在同一個專jar包這么寫,

Java代碼

<importresource="classpath:/applicationContext-action.xml"/>

要導入其它jar包中屬的配置文件,這么寫

Java代碼

<importresource="classpath*:/applicationContext-service.xml"/>

就這么簡單,重新打包、部署、啟動成功。

閱讀全文

與javamaven配置文件相關的資料

熱點內容
湯姆貓是什麼網站 瀏覽:913
失易得數據恢復怎麼把照片 瀏覽:185
電腦只顯示1個網路 瀏覽:607
數控加工與編程專業怎麼樣 瀏覽:4
西安程序員工資 瀏覽:389
表格怎麼添加一行數據 瀏覽:35
旅遊網站開發怎麼選 瀏覽:669
properties文件位置 瀏覽:679
不想學編程可以做什麼 瀏覽:22
手機照片一鍵壓縮成文件 瀏覽:962
女生微信霸氣個性簽名 瀏覽:626
微博如何看別人一個月的數據 瀏覽:14
萬能小組件怎麼點擊就進入app應用 瀏覽:817
蘋果5s變形怎麼恢復 瀏覽:286
電腦里文件密碼忘了咋辦啊 瀏覽:315
輸入文件夾 瀏覽:31
extjsgrid刪除列 瀏覽:43
gdx文件怎麼打開 瀏覽:759
如何更新大數據量表 瀏覽:311
特殊量產工具 瀏覽:980

友情鏈接