Home  >  Article  >  Java  >  What is the Maven packaging method and the method of executing jar in Java?

What is the Maven packaging method and the method of executing jar in Java?

王林
王林forward
2023-05-10 18:22:141077browse

    Maven packaging method and execution jar

    1. Jar

    1.1 Pom.xml
            
                
                    org.apache.maven.plugins
                    maven-compiler-plugin
                    3.8.1
                    
                        1.8
                        1.8
                        UTF-8
                    
                
                
                    org.springframework.boot
                    spring-boot-maven-plugin
                
            
    1.2 Run

    java -jar hello-world-0.0.1-SNAPSHOT.jar

    1.3 Automatic execution method

    What is the Maven packaging method and the method of executing jar in Java?

    2. Assembl1y

    2.1 Pom.xml

    What is the Maven packaging method and the method of executing jar in Java?

    2.2 Run

    java -classpath hello -world-0.0.1-SNAPSHOT.jar com.demo.controller.HelloController

    2.3 Method to be executed
    public class HelloController {
    
        public static void main(String[] args) {
            for (int x = 0; x < 100 ; x++) {
                System.out.println("this is " +i+ " test");
            }
        }

    3. Awakening

    Those who can see the essence of something in one second and those who spend half a lifetime unable to see the essence of something clearly have different fates.

    The above is the detailed content of What is the Maven packaging method and the method of executing jar in Java?. For more information, please follow other related articles on the PHP Chinese website!

    Statement:
    This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete