学习笔记-Maven(二)

多环境配置与应用

多环境开发

在实际的开发中,我们连接的数据库不唯一,一般都是开发时一个数据库,测试时一个库,实际生产一个库,这时候我们就需要使用多环境开发。

我们可以设定属性activation  activeByDefault来设置默认环境。

<!--        配置多环境-->
    <profiles>
        <!--开发环境-->
        <profile>
            <id>env_dep</id>
            <properties>
                <jdbc.url>jdbc:mysql://127.1.1.1:3306/thesecondcast?useSSL=false</jdbc.url>
            </properties>
            <!--设置是否为默认环境-->
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
        </profile>
        <!--生产环境-->
        <profile>
            <id>env_pro</id>
            <properties>
                <jdbc.url>jdbc:mysql://127.2.2.2:3306/thesecondcast?useSSL=false</jdbc.url>
            </properties>
        </profile>
        <!--测试环境-->
        <profile>
            <id>env_test</id>
            <properties>
                <jdbc.url>jdbc:mysql://127.3.3.3:3306/thesecondcast?useSSL=false</jdbc.url>
            </properties>
        </profile>
    </profiles>

此时运行,连接的则是开发环境设置的url。

但这般设置,想要修改的时候很麻烦,每次都得设置默认启动项,实际开发有一种更简便的方法。根据ID来启动。

在IDEA打开Maven侧栏,点击此按钮,输入上面的指令,就可以启动了。

跳过测试

点击此按钮,跳过所有的测试。

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.12.4</version>
                <configuration>
                    <skipTests>false</skipTests>
                 <!-- 排除不参与的测试内容-->
                    <excludes>
                        <exclude>**/BookServiceTest.java</exclude>
                    </excludes> 
                </configuration>
            </plugin>
        </plugins>

此项目只有BookServiceTest 一个测试类,exclude后执行应该不执行测试方法。

还可使用指令来跳过测试,以后跳过测试指令是最常用的:

私服

(目前并未下载到Nexus软件,还未能好好学习私服)

私服是一台独立的服务器,用于解决团队内部的资源共享与资源同步问题。

Nexus:

私服仓库分类

本地仓库访问私服配置

私服资源的上传与下载

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值