Я думаю, что причина ошибки связана с классом MyWebMvcConfigurerAdapter, который может успешно упаковать упаковку, удалив его.
Программа может быть успешно упакована путем удаления класса MyWebMvcConfigurerAdapter
@Configuration
public class MyWebMvcConfigurerAdapter implements WebMvcConfigurer {
/**
*
* @param registry
*/
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
ApplicationHome home = new ApplicationHome(getClass());
File jarFile = home.getSource();
registry.addResourceHandler("/static/**")
.addResourceLocations("classpath:/META-INF/resources/")
.addResourceLocations("classpath:/resources/")
.addResourceLocations("classpath:/static/")
.addResourceLocations("classpath:/public/")
.addResourceLocations("classpath:/META-INF/resources/WEB-INF/static/")
.addResourceLocations("file:"+jarFile.getParentFile().toString()+"\\static\\");
}
}
Caused by: java.lang.NullPointerException: null
at com.hzh.menu.follow_your_heart.client.config.webconfig.MyWebMvcConfigurerAdapter.addResourceHandlers(MyWebMvcConfigurerAdapter.java:27)
at org.springframework.web.servlet.config.annotation.WebMvcConfigurerComposite.addResourceHandlers(WebMvcConfigurerComposite.java:95)
at org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration.addResourceHandlers(DelegatingWebMvcConfiguration.java:88)
at org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport.resourceHandlerMapping(WebMvcConfigurationSupport.java:490)
at org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration$$EnhancerBySpringCGLIB$$ef76c66.CGLIB$resourceHandlerMapping$38(<generated>)
at org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration$$EnhancerBySpringCGLIB$$ef76c66$$FastClassBySpringCGLIB$$a1243485.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:363)
at org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration$$EnhancerBySpringCGLIB$$ef76c66.resourceHandlerMapping(<generated>)
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:498)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
... 46 common frames omitted
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 12.824 s <<< FAILURE! - in com.hzh.menu.follow_your_heart.FollowYourHeartApplicationTests
[ERROR] contextLoads(com.hzh.menu.follow_your_heart.FollowYourHeartApplicationTests) Time elapsed: 0.018 s <<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'resourceHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method 'resourceHandlerMapping' threw exception; nested exception is java.lang.NullPointerException
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method 'resourceHandlerMapping' threw exception; nested exception is java.lang.NullPointerException
Caused by: java.lang.NullPointerException
Я надеюсь, что программа может быть успешно упакована