Get the App
SLTechnology News&Howtos  ›  Development  › 

How to solve the problem that the project can be run in idea and the jar package cannot be run?

Shulou Source: shulou.com Published: 2022-06-03 07:04:12 09月30日 Update

This article introduces the knowledge about "how to solve the problem that the project can run in idea but the jar package can't run". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!

Problems encountered: the project in idea can run, but the jar package can not run

Error reason: class in timed task class cannot get some beans from context, or Netty class cannot get some beans from context; delay in scheduleConfig configuration class is 10000, and it can be run by packaging method in 2 and 3.

ScheduleConfig configuration file

package com.bst.framework.config;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import org.springframework.scheduling.quartz.SchedulerFactoryBean;import javax.sql.DataSource;import java.util.Properties;/** * Scheduled Task Configuration * * @author ruoyi */@Configurationpublic class ScheduleConfig{@Bean public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource) { SchedulerFactoryBean factory = new SchedulerFactoryBean(); factory.setDataSource(dataSource); // quartz parameter Properties prop = new Properties(); prop.put("org.quartz.scheduler.instanceName", "RuoyiScheduler"); prop.put("org.quartz.scheduler.instanceId", "AUTO"); //thread pool configuration prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool"); prop.put("org.quartz.threadPool.threadCount", "20"); prop.put("org.quartz.threadPool.threadPriority", "5"); // JobStore configuration prop.put("org.quartz.jobStore.class", "org.quartz.impl.jdbcjobstore.JobStoreTX"); //Cluster Configuration prop.put("org.quartz.jobStore.isClustered", "true"); prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000"); prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1"); prop.put("org.quartz.jobStore.txIsolationLevelSerializable", "true"); // sqlserver enabled // prop.put("org.quartz.jobStore.selectWithLockSQL", "SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ? "); prop.put("org.quartz.jobStore.misfireThreshold", "12000"); prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_"); factory.setQuartzProperties(prop); factory.setSchedulerName("RuoyiScheduler"); //delayed start factory.setStartupDelay(10000); //This one has a pit and needs to be studied carefully factory.setApplicationContextSchedulerContextKey("applicationContextKey"); //Optional, QuartzScheduler //Update existing jobs when starting, so that you don't have to delete qrtz_job_details table corresponding records every time you modify targetObject factory.setOverwriteExistingJobs(true); //Set autostart, default is true factory.setAutoStartup(true); return factory; }}

1. Idea plug-in packaging, this form of packaging is easy to encounter bugs, all kinds of beans can not be created.

2. Mvn Packaging:

https://blog.csdn.net/qq_36159851/article/details/79699193

mvn command not recognized: www.cnblogs.com/rgever/p/9824992.html

3. build Artifacts package this reliable number of specified main classes

https://blog.csdn.net/qq_43619459/article/details/108014917

"How to solve the problem that the project in idea can run, but the jar package can't run" is introduced here. Thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!

Tags: Run configure problem project up and down context task content more knowledge practical learned next no reason parameter command dilemma actual form Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Redmi Shulou Tech Info MariaDB Apple