maven

ArcheTypes provide

Maven Getting Started Guide

Java Spring 全栈 - git

Java Spring 全栈知识体系

瘳雪峰Java教程

Springboot 入门系列


shiro - git

10 Minute Tutorial on Apache Shiro

Shiro + JWT + Spring Boot Restful 简易教程

SpringBoot极简集成Shiro

Shiro使用Redis实现分布式会话与信息缓存

Shiro + JWT + Spring Boot Restful 简易教程

SpringBoot+Shiro+Jwt实现登录认证

SpringBoot使用Session

Spring Boot 中的 Session

SpringBoot系列:2.注册,登录与session

Spring Boot Security Role-based Authorization Tutorial

spring security - git

Spring Boot Registration and Login with MySQL Database Tutorial

spring-boot-registration-login

Springboot 使用Redis+Session实现Session共享

Spring boot 将 Session 放入 Redis

Spring Session - Spring Boot


Compile Maven Module with Different Java Version

Guide to Using Toolchains

Toolchains for JVM projects

Gradle Toolchains Support for JVM Projects

gradle java toolchain example

Building an Application with Spring Boot

Maven打包可执行jar包方法大全

./mvnw 镜像源
vim ./mvn/wrapper/maven-wrapper.properties
#distributionUrl=https://mirrors.cloud.tencent.com/apache/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.zip
#wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar
distributionUrl=https://mirrors.cloud.tencent.com/apache/maven/maven-3/3.9.8/binaries/apache-maven-3.9.8-bin.zip

安装mvnw
mvn wrapper:wrapper
mvn wrapper:wrapper -Dmaven=3.9.8
mvn clean install
./mvnw clean install

运行spring-boot程序
./mvnw sprint-boot:run
java -jar ./target/jarfile.jar com.mars.demo.Application 

打包配置

方法一:使用maven-jar-plugin和maven-dependency-plugin 
方法二:使用maven-assembly-plugin (推荐) 
方法三:使用maven-shade-plugin 
方法四:使用onejar-maven-plugin 
方法五:使用spring-boot-maven-plugin 
方法六:使用tomcat7-maven-plugin

使用maven-assembly-plugin 
maven-assembly-plugin可以将所有的东西都打包到一个jar包中
<plugin>
    <groupId>org.apache.maven.plugins</groupId><artifactId>maven-assembly-plugin</artifactId>
    <executions>
    <execution>
        <phase>package</phase>
        <goals>
            <goal>single</goal>
        </goals>
        <configuration>
            <archive>
                <manifest>
                <mainClass>
                    com.michealyang.jetty.embeded.EmbeddedJettyServer</mainClass>
                </manifest>
            </archive>
            <descriptorRefs>
                <descriptorRef>jar-with-dependencies</descriptorRef>
            </descriptorRefs>
        </configuration>
        </execution>
    </executions>
</plugin>

使用onejar-maven-plugin 
This provides custom classloader that knows how to load classes and resources from jars inside an archive, instead of from jars in the filesystem.
<plugin>
    <groupId>com.jolira</groupId><artifactId>onejar-maven-plugin</artifactId>
    <executions>
        <execution>
            <configuration>
                <mainClass>org.baeldung.executable.
                    ExecutableMavenJar
                </mainClass>
                <attachToBuild>true</attachToBuild>
                <filename>
                    ${project.build.finalName}.${project.packaging}
                </filename>
            </configuration>
            <goals>
                <goal>one-jar</goal>
            </goals>
        </execution>
    </executions>
</plugin>

使用spring-boot-maven-plugin 
能同时打可执行jar包和war包 This allows to package executable jar or war archives and run an application “in-place”.
<plugin>
    <groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId>
    <executions>
        <execution>
        <goals>
            <goal>repackage</goal>
        </goals>
        <configuration>
            <classifier>spring-boot</classifier>
            <mainClass>
                org.baeldung.executable.ExecutableMavenJar
            </mainClass>
        </configuration>
        </execution>
    </executions>
</plugin>

使用tomcat7-maven-plugin 
可打包成一个web工程类型的jar包。其实是内嵌了一个tomcat在里面。
<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.0</version>
    <executions>
        <execution><id>tomcat-run</id>
        <goals>
            <goal>exec-war-only</goal>
        </goals>
        <phase>package</phase>
        <configuration>
            <path>/</path>
            <enableNaming>false</enableNaming)
            <finalName>webapp.jar</finalName)
            <charset>utf-8</charset>
        </configuration>
        </execution>
    </executions>
</plugin>
更改当前环境
update-alternatives --config java
update-alternatives --config javac


#mvn -B archetype:generate -DgroupId=com.vicky.app -DartifactId=myapp -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4
mvn archetype:generate \
  -DarchetypeGroupId=org.apache.maven.archetypes \
  -DarchetypeArtifactId=maven-archetype-site \
  -DgroupId=com.mycompany.app \
  -DartifactId=my-app-site
  
mvn compile
mvn test
mvn test-compile
mvn package    #gen war
mvn install    #install to /root/.m2/
mvn site       #gen web
mvn clean

mvn exec:java -Dexec.mainClass="com.vicky.app"
mvn exec:java