intellij idea maven打jar包

3 篇文章 0 订阅
2 篇文章 0 订阅

1、maven配置文件settings.xml设置

在项目1级目录下新建maven/settings.xml
settings.xml文件内容如下

<?xml version="1.0" encoding="UTF-8"?>

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

    <mirrors>

        <mirror>
            <id>aliyun</id>
            <name>aliyun</name>
            <mirrorOf>central</mirrorOf>
            <url>https://maven.aliyun.com/repository/public</url>
        </mirror>
    </mirrors>

    <profiles>
        <profile>
            <id>jdk1.8</id>
            <activation>
                <activeByDefault>true</activeByDefault>
                <jdk>1.8</jdk>
            </activation>
            <properties>
                <maven.compiler.source>1.8</maven.compiler.source>
                <maven.compiler.target>1.8</maven.compiler.target>
                <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
            </properties>
        </profile>

        <profile>
            <id>sonar</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <sonar.login>admin</sonar.login>
                <sonar.password>123456</sonar.password>
                <sonar.host.url>http://192.168.12.110:9000</sonar.host.url>
            </properties>
        </profile>
    </profiles>

    <activeProfiles>
        <activeProfile>jdk18</activeProfile>
        <activeProfile>sonar</activeProfile>
    </activeProfiles>

    <!-- activeProfiles
     | List of profiles that are active for all builds.
     |
    <activeProfiles>
      <activeProfile>alwaysActiveProfile</activeProfile>
      <activeProfile>anotherAlwaysActiveProfile</activeProfile>
    </activeProfiles>
    -->
</settings>

在这里插入图片描述

引用settings.xml
-DarchetypeCatalog=internal

在这里插入图片描述
在这里插入图片描述

2、设置导出的jar包名称

在这里插入图片描述

3、编辑测试代码

如果出现如下错误,检测maven如上图所示的配置路径。并退出重新打开项目
java: 错误: 无效的源发行版:17

测试代码如下

package com.mydemo2.demo.Controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {
    @GetMapping("/test")
    public String test(){
        return "hello mydemo2 !!!";
    }
}

在这里插入图片描述

运行:运行–>新建配置–>左上角+号–>应用程序

在这里插入图片描述

4、导出为jar包

若不是第一次打包,先双击clean,后双击package

在这里插入图片描述
在这里插入图片描述

5、推送到gitlab中

在gitlab中新建仓库
复制ssh链接

在这里插入图片描述
在这里插入图片描述

配置idea
修改 .gitignore文件
修改内容为:target/ 修改为 target/**/

在这里插入图片描述

创建本地git仓库,略
添加远程仓库, git–管理远程–新建–添加ssh链接
推送–提交

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值