展开
拓展 关闭
订阅号推广码
GitHub
视频
公告栏 关闭

maven总结

  • 安装
点击查看详情
# 解压后,配置环境变量
MAVEN_HOME= C:\Program Files\apache-maven-3.6.3
Path= %MAVEN_HOME%\bin

# 配置setting.xml
# 指定本地仓库
<localRepository>C:\Users\ychen\.m2\repository</localRepository>

# 指定用户名密码
<servers>
  <server>
    <id>maven-releases</id>
    <username>admin</username>
    <password>admin</password>
  </server>
  <server>
    <id>maven-snapshots</id>
    <username>admin</username>
    <password>admin</password>
  </server>
</servers>

# 指定阿里云镜像,通过该镜像获取jar
<mirrors>
  <mirror>
    <id>nexus-aliyun</id>
    <mirrorOf>central</mirrorOf>
    <name>Nexus aliyun</name>
    <url>http://maven.aliyun.com/nexus/content/groups/public</url>
  </mirror>
  <mirror>
    <id>nexus-ychen</id>
    <mirrorOf>*</mirrorOf>   
    <url>http://xxx.xxx.xxx.xxx:8081/repository/maven-public/</url>
  </mirror>
</mirrors>

# 将maven安装目录下的settings.xml复制到C:\Users\本机名\.m2

# 打开cmd测试
mvn -v
  • idea配置
点击查看详情

  • 项目配置
点击查看详情
  • pom
<dependencies>
    <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <version>2.7.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-test -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <version>2.7.0</version>
        <scope>test</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-configuration-processor -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-configuration-processor</artifactId>
        <version>2.7.0</version>
    </dependency>
    <!-- mybatis plus -->
    <dependency>
        <groupId>com.baomidou</groupId>
        <artifactId>mybatis-plus-boot-starter</artifactId>
        <version>3.5.1</version>
    </dependency>
    <!-- 连接查询 -->
    <dependency>
        <groupId>com.github.yulichang</groupId>
        <artifactId>mybatis-plus-join</artifactId>
        <version>1.2.4</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>8.0.29</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.18.22</version>
        <scope>provided</scope>
    </dependency>
    <!-- fastjson -->
    <dependency>
        <groupId>com.alibaba</groupId>
        <artifactId>fastjson</artifactId>
        <version>1.2.78</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-validation -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-validation</artifactId>
        <version>2.7.0</version>
    </dependency>
</dependencies>
  • yml
# 配置yml
server:
  port: 8080
  error:
    whitelabel:
      enabled: true      # 使用自定义错误页
spring:
  application:
    name: app      # 项目名
  messages:
    basename: messages
    encoding: UTF-8      # 国际化
  devtools:
    restart:
      enabled: true      # 热部署
logging:
  level:
    com:
      example: DEBUG
    org:
      springframework:
        security: DEBUG
  pattern:
    console: '%clr(%d{E HH:mm:ss.SSS}){blue} %clr(%-5p) %clr(${PID}){faint} %clr(---){faint}      # 控制台日志
              %clr([%8.15t]){cyan} %clr(%-40.40logger{0}){blue} %clr(:){red} %clr(%m){faint}%n'
@Data
@TableName("plate_set")
public class PlateSet implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private String id;

    @TableField(value = "created", fill = FieldFill.INSERT)
    private Date created;

    @TableField(value = "updated", fill = FieldFill.INSERT_UPDATE)
    private Date updated;

    @TableField(value = "deleted", fill = FieldFill.INSERT)
    @TableLogic
    private Integer deleted;

    @TableField(value = "version", fill = FieldFill.INSERT)
    @Version
    private Integer version;

}
  • 热部署 -> 链接

  • 打包部署

点击查看详情
<build>
   <plugins>
      <plugin>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-maven-plugin</artifactId>
          <version>2.3.7.RELEASE</version>
      </plugin>
  </plugins>
</build>
  • 发布
点击查看详情
<distributionManagement>
    <repository>
        <id>maven-release</id>
        <url>http://xxx.xxx.xxx.xxx:8081/repository/maven-releases/</url>
    </repository>
    <snapshotRepository>
        <id>maven-snapshots</id>
        <url>http://xxx.xxx.xxx.xxx:8081/repository/maven-snapshots/</url>
    </snapshotRepository>
</distributionManagement>
posted @ 2022-08-16 05:48  DogLeftover  阅读(15)  评论(0编辑  收藏  举报