Tag Archives: jar

An error was reported when Maven package was running the packaged jar package: there is no main list attribute in xxx.jar, which can be solved by configuring Maven plugin

The command line runs the packaged jar package:

leung@wuyujin simple-webservice-server % java -jar target/sample-1.0-SNAPSHOT.jar 7896
target/sample-1.0-SNAPSHOT.jar There is no master list property in the

Error reason: there is no manifest file in the packaged jar package, which has two lines of configuration, about the full path of the startup class of jar package 0

Add Maven plugin

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-jar-plugin</artifactId>
	<version>3.0.2</version>
	<configuration>
		 <archive>
		  <manifest>
			   <addClasspath>true</addClasspath>
			   <classpathPrefix>lib/</classpathPrefix>
			   <mainClass>com.coffee.bee.Main</mainClass>
		  </manifest>
		 </archive>
	</configuration>
</plugin>

Plugins
pluginManagement > plugins

package xxx does not exist cannot find symbol

When deploying services on Linux, a large number of packages were thrown and no exception was found

[ERROR] /home/jenkins/agent/workspace/pipeline_p-h6sbk-4/src/main/java/com/UserServiceImpl.java:[3,28] package com.alibaba.fastjson does not exist

[ERROR] /home/jenkins/agent/workspace/pipeline_p-h6sbk-4/src/main/java/com/User.java:[9,2] cannot find symbol

[ERROR]   symbol: class Data

[ERROR]   location: class com.xxx

[ERROR] /home/jenkins/agent/workspace/pipeline_p-h6sbk-4/src/main/java/com/User.java:[3,14] package lombok does not exist

[ERROR] /home/jenkins/agent/workspace/pipeline_p-h6sbk-4/src/main/java/com/User.java:[9,2] cannot find symbol

[ERROR]   symbol: class Data

[ERROR]   location: class com.xxx

[ERROR] -> [Help 1]

[ERROR] 

[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

[ERROR] Re-run Maven using the -X switch to enable full debug logging.

[ERROR] 

[ERROR] For more information about the errors and possible solutions, please read the following articles:

[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

This is Maven’s problem

    check whether the settings.xml file is configured. Check & lt; in the settings.xml file; localRepository> If the path is configured correctly, & lt; mirror> Whether the image address is correct and the network is unblocked. Whether the jar package and the corresponding version exist in Maven warehouse. Whether the Maven version configured in pom.xml corresponds to the Linux Installation version

Update project manually_ Solution of too large jar package in springboot

1. Problem scenario

Project update, upload the entire jar package, too large, resulting in long upload time, update or upgrade too slow.

2. Solutions

1) Store jars that are not updated frequently in a separate folder LIBS.

2) Frequently updated jars are typed as one jar.

3、 pom.xml to configure

1) The final jar package contains the updated jar package

2) Folder LIBS kicks out jars that are often updated

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/libs</outputDirectory>
                            <overWriteIfNewer>true</overWriteIfNewer>
                            <includeScope>runtime</includeScope>
                            <excludeGroupIds>com.mp,com.mp.common.spring,com.mp.common.util</excludeGroupIds>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <layout>ZIP</layout>
                    <includes>
                        <include>
                            <groupId>com.mp</groupId>
                            <artifactId>mp-dispatch-service-api</artifactId>
                        </include>
                        <include>
                            <groupId>com.mp.common.spring</groupId>
                            <artifactId>common-spring-jpa</artifactId>
                        </include>
                        <include>
                            <groupId>com.mp.common.spring</groupId>
                            <artifactId>common-spring-base</artifactId>
                        </include>
                        <include>
                            <groupId>com.mp.common.util</groupId>
                            <artifactId>common-util</artifactId>
                        </include>
                    </includes>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                            <goal>build-info</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
        </plugins>
    </build>

 

Idea introduces dependency and starts jar error in opening zip file

Question:

reason:

When Maven download is dependent, the jar may not be downloaded to the local normally due to network reasons. If you start the project reference, an error will be reported, and the local Maven jar cannot be used normally

terms of settlement:

There is a stupid way to find out which jars are open with errors. Find the corresponding jars in the local Maven repository and delete them, pom.xml After testing, no error will be reported

pom.xml Depending on the error report, the problem of missing artifact XXX is solved

pom.xml Depending on the error report, the problem of missing artifact XXX is solved

Possible causes pom.xml The dependency configuration format specifies that you manually download the corresponding jar and then install it to the local repository pom.xml After modification

Eclipse imports or creates a new Maven project, pom.xml An error is reported in the configuration file, missing artifact XXX jar. The problem is that the jar package is not found in the specified warehouse after Maven is started.

Possible causes

    there is no such jar package in the central warehouse or local warehouse; some jar packages are charged (for example, Oracle) ojdbc.jar In fact, there is no such resource in Maven Central Library, so it cannot be loaded; pom.xml Configuration items do not match.

pom.xml Dependency configuration format description

// pom.xml
<dependencies>
		<dependency>
			<groupId>Package1</groupId>
			<artifactId>jarName</artifactId>
			<version>versionInJar</version>
		</dependency>
		<dependency>
			<groupId>Package2</groupId>
			<artifactId>jarName2</artifactId>
			<version>1.0.0</version>
		</dependency>
		......
</dependencies>

Groupid: the relative path of the dependent jar package. The parent-child directory is marked with “.” (example: package.packageNext ); artifactid: dependent jar package name; version: dependent jar package version.

Manually download the corresponding jar, and then install it to the local warehouse

    download the corresponding version of the jar package; open the CMD, preferably in the path to be installed (the installation command is more convenient, directly in the address bar of the path to be installed, enter CMD to quickly open the command window); install here. Take Ojdbc14 as an example, after opening CMD, enter the command as follows:

    mvn install:install-file -Dpackaging=jar -DgroupId= com.oracle -DartifactId=ojdbc14 -Dversion=11.2.0.3.0 -Dfile=ojdbc14-11.2.0.3.0.jar -DgeneratePom=true

    Command explanation:
    install: compile and package the project to the local warehouse;
    install file: install file;
    – dgroupid= com.oracle : Specifies that the groupid of the current package is com.oracle ;
    – dartifactid = Ojdbc14: Specifies that the current artifact ID is Ojdbc14;
    – dversion = 11.2.0.3.0: Specifies that the current package version is 11.2.0.3.0;
    – dversion = 11.2.0.3.0 -Dfile = D: ojdbc14-11.2.0.3.0.jar: Specifies the file location of the package to be typed (the reason why you want to open CMD in the path before is to avoid entering an excessively long path);
    – dgeneratepom = true: whether to generate a POM file.

      open the Maven project in eclipse, right-click Maven – & gt; update or click open pom.xml File, right-click Maven – & gt; update for project.

    pom.xml After modification

    <dependency>
    			<groupId>com.oracle</groupId>
    			<artifactId>ojdbc14</artifactId>
    			<version>11.2.0.3.0</version>
    </dependency>
    

Research on Maven management of Java project pom.xml The jar package error is reported, but the project is running normally

Today, I always make mistakes when building projects. I suspect that there is something wrong with the jar package, so I delete all the jar packages and reload them into the Maven warehouse,

Think very good, but made a mistake! POM file error, how to update all useless, delete jar package reload also can’t.

Finally, in the life and death of the occasion, choose the forced refresh, just like, then remember it!

Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:3.0.0:clean (default-clean) on

Failed to execute goal org, apache maven. Plugins: maven – clean – plugin: 3.0.0: clean (default – the clean) on project springboot1: Failed to clean project: Failed to delete the F: \ springboot1 \ target – & gt;
To see the full stack trace of the errors, re-run Maven with the -e switch.
The cause of this problem is that the CMD command window to start Springboot1 is open under the target file path of the project Springboot1. This causes the package Springboot1 project to fail. To see the full stack trace of the errors, re-run Maven with the -e switch. You need to shut down a Maven and reopen it.
Solution: Close the CMD command window that starts Springboot1. Just pack it up again.

Zip to decompress the jar package, like the add file in the jar package

1. A JAR is just a ZIP package that can be unzip, and the possible path of unzip files is exactly the same.
2. If the JAR package contains exactly the same file, the ZIP add will not be used and a zip error will be reported: zip file structure invalid
3. Add classes to a JAR package, such as classes from the compiled classes, go to the classes directory and use the command zip-r your. Jar./*
4. The FAT JAR packaged with assembly may not contain its own classes, so use the methods in 3 to ensure that the JAR contains its own classes