账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    springboot+struts2打成jar包运行
    58
    0

    springboot集成struts2,在开发工具(eclipse)运行正常。打成jar包或war包,使用java -jar执行,均会出现以下错误:求如何解决?

        java.lang.NullPointerException: null
        at com.opensymphony.xwork2.util.fs.JarEntryRevision.build(JarEntryRevision.java:52) ~[xwork-core-2.3.32.jar!/:2.3.32]
        at com.opensymphony.xwork2.util.fs.DefaultFileManager.monitorFile(DefaultFileManager.java:97) [xwork-core-2.3.32.jar!/:2.3.32]
        at com.opensymphony.xwork2.util.fs.DefaultFileManager.loadFile(DefaultFileManager.java:74) [xwork-core-2.3.32.jar!/:2.3.32]
        at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:1015) [xwork-core-2.3.32.jar!/:2.3.32]
        at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadDocuments(XmlConfigurationProvider.java:167) [xwork-core-2.3.32.jar!/:2.3.32]
        at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.init(XmlConfigurationProvider.java:134) [xwork-core-2.3.32.jar!/:2.3.32]
        at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:239) [xwork-core-2.3.32.jar!/:2.3.32]
        at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67) [xwork-core-2.3.32.jar!/:2.3.32]
        at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:978) [struts2-core-2.3.32.jar!/:2.3.32]
        at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:446) [struts2-core-2.3.32.jar!/:2.3.32]
        at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:490) [struts2-core-2.3.32.jar!/:2.3.32]
        at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74) [struts2-core-2.3.32.jar!/:2.3.32]
        at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57) [struts2-core-2.3.32.jar!/:2.3.32]
        at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:285) [tomcat-embed-core-8.5.16.jar!/:8.5.16]
        at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:112) [tomcat-embed-core-8.5.16.jar!/:8.5.16]
        at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4590) [tomcat-embed-core-8.5.16.jar!/:8.5.16]
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5233) [tomcat-embed-core-8.5.16.jar!/:8.5.16]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.16.jar!/:8.5.16]
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419) [tomcat-embed-core-8.5.16.jar!/:8.5.16]
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409) [tomcat-embed-core-8.5.16.jar!/:8.5.16]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_11]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_11]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_11]
        at java.lang.Thread.run(Thread.java:745) [na:1.8.0_11]
    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • ↗冷殇ε 普通会员 1楼

      要将Spring Boot + Struts2 框架打包成 jar 包,并将其运行,你需要按照以下步骤操作:

      1. 首先,确保你的 Spring Boot 和 Struts2 应用都安装在你的机器上。你可以在 Spring Boot 的官方文档中找到更多的信息:https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/>

      2. 创建一个名为 application.properties 的文件,并在其中设置你的 Struts2 项目。例如:

      properties struts2.api.url=http://localhost:8080 struts2.ui.path=/WEB-INF/views struts2.jsp.maxSessionTime=60 struts2.jsp.showShowcase=true struts2.ui.action.out.printlnActionMessage=true

      这只是一个基本的示例,你可以根据需要自定义 Struts2 的设置。

      1. 使用 mvn clean package 命令清理你的项目。这将删除你的旧项目,并创建一个新的打jar包。

      2. 使用 jar 命令创建你的 jar 包。例如:

      mvn clean package -DskipTests jar -cvf your-project-name.jar your-project-name

      your-project-name.jar 替换为你希望保存的 jar 包名称。

      1. 现在,你可以使用 java -jar your-project-name.jar 运行你的 Spring Boot + Struts2 应用。

      注意:上述步骤适用于本地开发环境。如果你正在为生产环境使用,你可能需要在生产环境中添加更多的配置,例如修改 Spring Boot 的启动参数,或者在应用程序服务器上设置环境变量。

    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部