Tag Archives: maven

[Solved] Maven Error: The packaging for this project did not assign a file to the build artifact

Problem Description
	When using the maven function provided by idea to install a project, the console reports an error
	The packaging for this project did not assign a file to the build artifact
Problem Analysis
	This is to say that the package for the plugin could not be found, in fact, it is not that the package for the plugin could not be found, but that the project did not load the package from the maven repository into the project
Problem solving
	The use of their own is the install under plugins caused by
	should use the Lifecycle install normal operation

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:

[email protected] 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

‘dependencies.dependency.version‘ for org.springframework.cloud:spring-cloud-starter-openfeign:jar

‘dependencies.dependency.version’ for org.springframework. cloud:spring-cloud-starter-openfeign :jar is missing. @ line 29, column 21

The error is as follows:

terms of settlement:

Delete local Maven warehouse (Maven)_ repository)

Or adjust the location of the local Maven warehouse, pull the project again, and then build it with Maven.

 
 

Error in Maven clean or package

1. Run the MVN – V command and report an error. Java.io.filenotfoundexception: F:: (java-maven-apache-maven-3.6.3) bin…/conf/logging

just create a logging folder

2. My java development and learning journey; Java NiO reports java.nio.charset.malformedinputexception: input length = 1 exception
I show that all encoding in idea is set to UTF-8, and check

, but it still can’t
and then read this blog: https://blog.csdn.net/ouyang_ Peng/article/details/46462379
, delete the Chinese garbled code in application.properties and rewrite it in Chinese.

By the way, when using terminal to build MVN package in idea, you can add – x,
that is

mvn package -X

In this way, you can see the specific error log

Error in STS importing POM file of Maven project

Today, we use STS to import Maven project, install the document installation software and load the document all the way, but after the import project is opened, we always report an error, POM file reports an error, and we can’t find the third-party jar package written by the company. Check it again and again, and there is no error in the process

Colleagues help to check, replace the local library, can not solve. Finally, the settings file of Maven was replaced.

Reason: in the old version of maven, the settings file has not been modified. I don’t know where there is a problem. I can’t find the company’s private jar package. I replaced my colleagues’ settings file to solve the problem.

Idea: POM file error, check Maven installation settings, especially settings file.

How to Solve Error: Failed to execute goal org.codehaus.mojo:……..

How to Solve:Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (default-cli) on project spring_aop: Command execution failed.error


error:

Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (default-cli) on project 
spring_aop: Command execution failed.

Solution 1: in this case, I will use the main method to execute the program and use the unit test @ test instead

~It used to be like this: running with main

public class MyTest {
    public static void main(String[] args) {
    
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");

        //Dynamic proxies represent interfaces
        UserService userservice = (UserService) context.getBean("userservice");

        userservice.add();
    }
}

~Changed to: use @ test

import com.niuyun.service.UserService;
import com.niuyun.service.UserServiceImpl;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class MyTest {

    @Test
    public void test(){
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");

        //Dynamic proxies represent interfaces
        UserService userservice = (UserService) context.getBean("userservice");

        userservice.add();
    }
}

~Finish the work and run successfully

! Expansion

@Test is the basis of JUnit testing, and its functions are as follows:
1. Specify the type of exception to be thrown
2. Test the running time of the code.


Solution 2: if you have to use the main function, you can introduce two plug-ins in Maven (compiler can not be introduced), but it may lead to Chinese garbled.

Maven compiler plugin: used to compile java files, specify JDK version, etc.
exec Maven plugin: used to execute class files, in which the path of executing class should be indicated in plug-in configuration.

<build>
     <plugins>
         <plugin>
             <groupId>org.codehaus.mojo</groupId>
             <artifactId>exec-maven-plugin</artifactId>
             <version>1.6.0</version>
             <executions>
                 <execution>
                     <goals>
                         <goal>java</goal>
                     </goals>
                 </execution>
             </executions>
             <configuration>
                 <classpathScope>test</classpathScope>
             </configuration>
         </plugin>
     </plugins>
</build>

~Run successfully


Solve the problem of garbled code

Method 1:
in setting – & gt; maven-> Runner-> Fill in the column VM options
with – dfile. Encoding = GB2312

Method 2: add in pom.xml (I tried this method, but I didn’t solve the garbled code, which may be useful to you)

<properties>
	<!-- Encoding when copying files -->
	<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
	<!-- Compile-time coding -->
    <maven.compiler.encoding>UTF-8</maven.compiler.encoding>
</properties> 

Springboot Error: There was an unexpected error (type = internal server error, status = 500)

There was an unexpected error (type=Internal Server Error, status=500).
This error was found in running springboot.

There was an unexpected error (type=Internal Server Error, status=500).
Authentication failed for token submission [org.apache.shiro.authc. UsernamePasswordToken – null, rememberMe=false]. Possible unexpected error?(Typical or expected login exceptions should extend from AuthenticationException).
I had to rewrite it and found out that it was caused by Maven and the Thymeleaf dependency was added incorrectly.
Maybe I wrote it and @{} didn’t work correctly, so I took one from the internet and got the wrong one.
The original dependency was this

<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

I ended up with this

<!-- https://mvnrepository.com/artifact/org.thymeleaf/thymeleaf -->
<dependency>
    <groupId>org.thymeleaf</groupId>
    <artifactId>thymeleaf</artifactId>
    <version>3.0.12.RELEASE</version>
</dependency>

How to Solve FATAL ERROR in native method: JDWP on getting class status, jvmtiError=JVMTI_ERROR_WRONG_PHASE

I. Error reporting Experience:
Today, while using Eclipse to launch through Maven Build, an error occurred as shown below
II. Analysis of problems:
This is due to the fact that eclipse’s JRE is not configured
Iii. Problem Solving:
Step1 reconfigure the jre for eclipse
Open Window- Preferences- Java- Installed JREs, as shown in the figure below:

Step2 configure the JRE for maven build
Right-click on the project, and select Run As–Run Configurations:
Add the following code to the JRE TAB (modify the values based on your computer) :
-DMAVEN_OPTS=-Xms1024M -Xmx1024M -XX:PermSize=256M -XX:MaxPermSize=256M
As shown in the figure:

Iv. Startup:
Finally, you’re ready to start:

OK, GAME OVER !

Springboot Run Error: java.lang.NoClassDefFoundError: org/eclipse/jetty/server/Handler

1. Problem description


Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
[APP_IS_UNDEFINED:10.164.194.116:0000] [,,,] 2021-05-05 10:08:54.933 ERROR 18128 [main] org.springframework.boot.SpringApplication Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'xxlJobExecutor' defined in class path resource [com/haiercash/marketcontrol/schedule/config/XxlJobConfig.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/eclipse/jetty/server/Handler
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1778)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
	at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$168/331510866.getObject(Unknown Source)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:843)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
	at com.haiercash.marketcontrol.schedule.ScheduleApplication.main(ScheduleApplication.java:27)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
	at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Caused by: java.lang.NoClassDefFoundError: org/eclipse/jetty/server/Handler
	at com.xxl.job.core.rpc.netcom.jetty.server.JettyServer.start(JettyServer.java:23)
	at com.xxl.job.core.rpc.netcom.NetComServerFactory.start(NetComServerFactory.java:25)
	at com.xxl.job.core.executor.XxlJobExecutor.start(XxlJobExecutor.java:60)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1903)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1846)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1774)
	... 25 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.server.Handler
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:93)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 35 common frames omitted

[APP_IS_UNDEFINED:10.164.194.116:0000] [,,,] 2021-05-05 10:09:07.905 INFO 29248 [AsyncResolver-bootstrap-executor-0] com.netflix.discovery.shared.resolver.aws.ConfigClusterResolver Resolving eureka endpoints via configuration
[APP_IS_UNDEFINED:10.164.194.116:0000] [,,,] 2021-05-05 10:09:22.905 INFO 29248 [AsyncResolver-bootstrap-executor-0] com.netflix.discovery.shared.resolver.aws.ConfigClusterResolver Resolving eureka endpoints via configuration
^Z
[3]+  Stopped                 tail -f detail.2021-05-05.0.log

2. Solutions

gradle

// https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-servlet
implementation group: 'org.eclipse.jetty', name: 'jetty-servlet', version: '9.4.35.v20201120'

maven

<!-- https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-servlet -->
<dependency>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-servlet</artifactId>
    <version>9.4.35.v20201120</version>
</dependency>

Cannot resolve reference to bean ‘sqlSessionFactory‘ while setting bean property ‘sqlSessionFactory‘

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘collectionService’: Unsatisfied dependency expressed through field ‘collectionDao’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘collectionDao’ defined in file [E:\IdeaProjects\myMusic\target\track-stacking\WEB-INF\classes\com\hechenbo\trackstacking\dao\CollectionDao.class]: Cannot resolve reference to bean ‘sqlSessionFactory’ while setting bean property ‘sqlSessionFactory’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sqlSessionFactory’ defined in class path resource [bean.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type ‘java.lang.String’ to required type ‘org.springframework.core.io.Resource[]’ for property ‘mapperLocations’; nested exception is java.lang.IllegalArgumentException: Could not resolve resource location pattern [classpath:com/hechenbo/trackstacking/dao/impl/*.xml]: class path resource [com/hechenbo/trackstacking/dao/impl/] cannot be resolved to URL because it does not exist

Error creating bean with name ‘collectionDao’ defined in file [E:\IdeaProjects\myMusic\target\track-stacking\WEB-INF\classes\com\hechenbo\trackstacking\dao\CollectionDao.class]
maven will compile and package the file will miss the xml file, when starting tomcat can not find the xml file, in all configuration files are no problem, the target folder does not contain the mapping xml file.
The xml file is not packaged by maven under the target. Add it to the <build> tag in pom.xml:

<resources>
          <resource>
              <directory>src/main/java</directory>
              <includes>
                  <include>**/*.xml</include>
              </includes>
              <filtering>true</filtering>
          </resource>
      </resources>

Then clean in Maven and restart Tomcat to display the mapping XML file in the class directory

Error assembling WAR: Problem creating war: Execution exception (and the archive is probably corrup

Using idea development, Maven build error:

 Error assembling WAR: Problem creating war: Execution exception (and the archive is probably corrupt but I could not delete it)

The cause of the error is that the memory of the JVM is not enough, so it’s better to configure it. The steps are as follows:

So we modify Maven’s JVM parameters directly in idea,

file-> setting-> Build,Execution,Deployment-> Maven-> Runner

Set the JVM parameter in VM option column, – xmx1g – XX: maxmetaspacesize = 128M

After setting, click Install on the right side to start the compilation, the parameter takes effect, and the maximum heap memory becomes 1g
0