spring项目下写个界面idea可以运行,maven打包jar报错,界面类空指针

吖hang 发布于 昨天 16:28
阅读 77
收藏 0

spring主函数入口

public static void main(String[] args) {
        System.setProperty("java.awt.headless", "false");
        SpringApplication.run(DemoApplication.class, args);
    }

界面代码

@Component
public class T extends JFrame {
	//内容没写,
}

酷乐棋牌_[官网入口]原本没有继承JFrame之前项目可以运行,T.class可以实例化。
继承之后报如下错误;

java.awt.HeadlessException: null

然后在主函数加System.setProperty("java.awt.headless", "false");后可以在idea正常运行。
但是用maven打包成jar又报错了,错误如下;

[ERROR] contextLoads  Time elapsed: 0.001 s  <<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 't' defined in file [D:\JavaPorject\com\Stock\target\classes\com\example\demo\utils\T.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.example.demo.utils.T]: Constructor threw exception; nested exception is java.awt.HeadlessException
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.example.demo.utils.T]: Constructor threw exception; nested exception is java.awt.HeadlessException
Caused by: java.awt.HeadlessException

找了几个方法都是都能解决在idra运行,但是用maven打包成jar就会报错。

请问一下改如何解决?谢谢!

加载中
0
f
freezingsky
这种问IDE问题的,帮不上忙😀
返回顶部
顶部

页面底部区域 foot.htm