Home > Java > javaTutorial > 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?

王林
Release: 2023-05-10 18:22:14
forward
1246 people have browsed it

    Maven packaging method and execution jar

    1. Jar

    1.1 Pom.xml
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.8.1</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                        <encoding>UTF-8</encoding>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
            </plugins>
    Copy after login
    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");
            }
        }
    Copy after login

    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!

    Related labels:
    source:yisu.com
    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template