javamaven配置文件|Maven-Spring多项目加载配置文件

Ⅰ 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.xml2,在applicationContext.xml引用其它的配置文件:如果在同一个专jar包这么写,

Java代码

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

要导入其它jar包中属的配置文件,这么写

Java代码

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

就这么简单,重新打包、部署、启动成功。


赞 (0)