Maven学习

Stella981
• 阅读 452

Maven Profile

通过使用profile可以根据不同的环境和目标做出不同的编译打包行为,如下pom文件

<profiles>  
    <profile>  
        <id>dev</id>  
        xxxx
    </profile>  
    <profile>  
        <id>test</id>  
        xxxx
    </profile>  
</profiles>  

执行mvn package -P dev则按照测试环境打包, 执行mvn package -P test则按照测试环境打包

通过Maven运行java类

一个maven工程,在控制台下想通过java命令直接运行某一个java类是非常困难的,因为很难解决依赖问题。这时使用maven命令能够很好的解决依赖的问题。

方法1

mvn exec:java -Dexec.mainClass="xxx"

方法2

<build>  
 <plugins>  
  <plugin>  
   <groupId>org.codehaus.mojo</groupId>  
   <artifactId>exec-maven-plugin</artifactId>  
   <version>1.1.1</version>  
   <executions>  
    <execution>  
     <phase>test</phase>  
     <goals>  
      <goal>java</goal>  
     </goals>  
     <configuration>  
      <mainClass>mainclass</mainClass>  
      <arguments>  
       <argument>arg0</argument>  
       <argument>arg1</argument>  
      </arguments>  
     </configuration>  
    </execution>  
   </executions>  
  </plugin>  
 </plugins>  
</build>  

方法3

方法3是利用profile对方法2的嵌套,目的为满足不同的需求

<profiles>  
 <profile>  
  <id>code-generator</id>  
  <build>  
   按照方法2补充这里的配置
  </build>  
 </profile>  
</profiles>
点赞
收藏
评论区
推荐文章
Easter79 Easter79
2年前
springboot中的@mvn.profile.active@ 不生效的原因
这个问题官方文档解释的很清楚,意思就是1,可以使用@..(https://my.oschina.net/u/57867)@的方式在application.yml或者application.properties文件中引用pom.xml文件中的属性变量(<properties标签下的子标签,包括激活的profile下的属性)2,可以通过一个mave
Easter79 Easter79
2年前
springboot分环境打包(maven动态选择环境)
分环境打包核心点:spring.profiles.activepom.xml中添加:<profiles<profile<iddev</id<activation<activeByDefaulttrue</activeB
Stella981 Stella981
2年前
Spring Boot 2.3 新特配置文件属性跟踪
背景当我们使用springboot在多环境打包,配置属性在不同环境的值不同,如下:spring:profiles:active:@project.profile@根据maven动态配置profilespring:profiles:devd
Stella981 Stella981
2年前
H265 Profile & Level & Tier 介绍
H265/HEVCProfileLevelTier档次、水平、等级为了提供不同应用之间的兼容互通,HEVC/H265定义了不同的编码Profile档次、Level水平、Tier等级。(1)profile规定了码流中使用了哪些编码工具和算法(2)Level中规定了对给定Profile、Tier所对应的解码器处理负担和
Wesley13 Wesley13
2年前
Linux的环境变量配置
Linux下设置变量有三种方法:第一种:在/etc/profile文件中添加变量【对所有用户生效(永久的)】  用VI在文件/etc/profile文件中增加变量,该变量将会对Linux下所有用户有效,并且是“永久的”。  例如:编辑/etc/profile文件,添加CLASSPATH变量  vi/etc/profile  
Wesley13 Wesley13
2年前
linux 添加java环境变量
在/etc/profile文件改权限.然后在终端输入sudogedit/etc/profile.或者用root用户直接编辑.在文件末尾添加如下几句:exportJAVA\_HOME/usr/java/jdk1.5exportPATH$JAVA\_HOME/bin:$PATHexportCLASSPATH.:$J
Stella981 Stella981
2年前
SpringBoot 项目的 Maven 多环境打包配置
1\.在pom.xml文件中配置<profiles<profile<iddev</id<activation<activeByDefaulttrue</activeByDefault</activation<properties
Wesley13 Wesley13
2年前
mysql 外键(foreign key)的详解和实例
外键具有保持数据完整性和一致性的机制,对业务处理有着很好的校验作用。白话简介user表:id为主键profile表:uid为主键简单来说,若表profile的uid列作为表外键(外建名称:user_profile),以表user 做为主表,以其id列做为参照(referenc
Stella981 Stella981
2年前
Gradle 生产与开发build.gradle配置不一样时打包(Springboot)
1.先说下缘由,项目没有使用配置中心,所以本地和开发有不同的build.gradle文件defenvSystem.getProperty("profile")?:"dev"if(env'prd'){applyfrom:"buildprd.gradle"}else{applyf
Stella981 Stella981
2年前
Qt安装后配置环境变量(Mac)
打开终端需要打开配置文件(注意这里不是bash\_profile而是.bash\_profile,我开始少了".")!(http://static.oschina.net/uploads/img/201603/11172956_Iz3m.png)如果bash\_profile文件不存在,就会自动创建,然后需要输入以下内容:!(http: