首页 \ 问答 \ Spring需要重新启动服务器才能刷新域对象(Spring needs a server restart to refresh domain objects)

Spring需要重新启动服务器才能刷新域对象(Spring needs a server restart to refresh domain objects)

球员:

我整个上午一直在打架,以便找到我的弹簧控制器的问题,这些问题在进入数据库并根据此类ddbb中的数据刷新表时无法正常工作。

我有一个单独的项目用于我的所有业务逻辑,我将其导出为JAR,并将其包含在我的Web spring MVC应用程序的lib文件夹(和类路径)中。 我有一个控制器用于这样的UploadCalendar.jsp,我从中实例化一个域服务(外部jar),理论上它进入数据库,在天和转(繁忙和可用)上抓取所有信息,然后绘制一个日历(表)上传到wordpress网站。 jsp只在整个外部服务类中运行进程的业务逻辑。

因为如果我从Web App外部运行uploadCalendar方法,它运行得很好,我很困惑为什么在Spring控制器中运行完全相同的方法,它不会更新日历。

我不得不说,通过我的服务类,我进入数据库,并将执行getCalendar()String方法所需的所有数据加载到内存中。 然后,我创建一个文件,并将该文件上传到远程服务器。

我不知道Spring是否会避免重新加载数据,即使数据被更改为ddbb?

我的Controller代码是这样的:

@Autowired
FileService fileService;

@Autowired
MainService main;

@RequestMapping(path="/uploadCalendar", method=RequestMethod.GET)
public ModelAndView UploadCalendar() throws IOException, DDBBException{
    //This, in theory, should get into the ddbb, and load all needed data
    main.loadAllTurns();

    //Runs getCalendar, takes the calendar string, and writes a local file
    fileService.WriteFile(main.getCalendarTableString(), conf.getCalendarFile2UploadURI());

    //Upload the file
    fileService.UploadFileFTP(conf.getCalendarFile2UploadURI(), conf.getCalendarRemoteFileURI());

    return new ModelAndView("/web/UploadCalendar.jsp");
}

我一直在进行大量的调试,只是为了发现它不是代码错误,但无论如何只是Web应用程序的一些缓存问题,因为如果我重新启动服务器,那么日历正确更新,文件正确更新,一切正常。 但是如果我再次进入数据库并更改一行,我还需要重新启动服务器以更新日历字符串。

你对这个问题有什么关系吗?


guys:

I've been fighting all morning in order to find what's the problem with my spring controller, which were not working properly while getting into the database and refreshing a table depending on the data within such ddbb.

I have a separate project for all of my business logic, which I export as a JAR, and include it into the lib folder (and classpath) of my web spring MVC app. And I have a controller for such an UploadCalendar.jsp, from which I instantiate a domain service (external jar) which in theory gets into the database, grabs all of the information on days and turns (busy and available), and then paints a calendar (table) to upload to a wordpress site. The jsp only runs the business logic of the process, throughout the external service class.

Since If I run the uploadCalendar method from outside the Web App, it runs perfectly, I get a lot confused why running the exact same method from within the Spring controller, it doesn't update the calendar.

I have to say that with my service class, I get into the database, and loads into memory all data needed to perform the getCalendar() String method. Then, I create a file, and upload that file to the remote server.

I don't know if it's Spring that is avoiding to reload the data, even when the data is changed into the ddbb?

My Controller code is like this:

@Autowired
FileService fileService;

@Autowired
MainService main;

@RequestMapping(path="/uploadCalendar", method=RequestMethod.GET)
public ModelAndView UploadCalendar() throws IOException, DDBBException{
    //This, in theory, should get into the ddbb, and load all needed data
    main.loadAllTurns();

    //Runs getCalendar, takes the calendar string, and writes a local file
    fileService.WriteFile(main.getCalendarTableString(), conf.getCalendarFile2UploadURI());

    //Upload the file
    fileService.UploadFileFTP(conf.getCalendarFile2UploadURI(), conf.getCalendarRemoteFileURI());

    return new ModelAndView("/web/UploadCalendar.jsp");
}

I have been making a lot of debug, just to find that it wasn't a code error, but just anyhow of some cache-problem with the web app, because if I restart the server, then the calendar is correctly updated, the file is correctly updated, and everything is ok. But if I just get into the database once again, and change a row, I also need a new restart of the server for the calendar string to be updated.

Do you have any idea on what the problem could be related to?


原文:https://stackoverflow.com/questions/34905020
更新时间:2022-07-01 08:07

最满意答案

mv path/to/your/executable_file /usr/local/bin/your_desied_command

示例mv composer.phar / usr / local / bin / composer


mv path/to/your/executable_file /usr/local/bin/your_desied_command

Example mv composer.phar /usr/local/bin/composer

相关问答

更多
  • .bashrc文件位于您的主目录中。 所以从命令行做: cd ls -a 这将显示您的主目录中的所有隐藏文件。 “cd”会让你回家,而ls -a会“列出所有”。 一般当你看到〜/ tilda斜杠是指你的主目录。 所以〜/ .bashrc是你的主目录.bashrc文件。 而自制软件的标准路径是/ usr / local /所以如果你: cd /usr/local ls | grep -i homebrew 你应该看到homebrew目录(/ usr / local / homebrew)。 资源 是的,有 ...
  • 本教程要求您通过执行emacs .bashrc来使用可扩展编辑器Emacs打开.bashrc文件。 然后你应该在文件末尾添加行source ~/ros/indigo/rbx_ws/devel/setup.bash 。 然后退出编辑器Emacs,按下“Cx Cc”按键,这意味着按下Control / CTRL键,按住它,然后先按'x'键然后按'c'键。 在此之后,您继续教程。 否则,你可以: 在您的终端中echo "source ~/ros/indigo/rbx_ws/devel/setup.bash" >> ...
  • 如果它们不存在,则应将它们放在主目录的根目录中。 You should make them in the root of your home directory, if they don't exist already.
  • 所以通过纯粹的运气,我正在寻找的答案出现在堆栈溢出侧边栏中。 这里解释了这个问题: 脚本中的source .bashrc不起作用 ,我将解释我是如何解决它的。 所以问题在于,每次我在Node或C程序中调用source , source总是在非交互式shell的环境中执行。 为了使它工作,你需要确保当source命令发生时,上下文是一个交互式shell,或者至少它看起来像一个。 我所做的是编译以下应用程序: #include int main() { putenv("PS1=B ...
  • Bash不会扩展~双引号内。 使用export PATH=~/bin:"$PATH"代替。 如果~/.bash_profile和~/.profile存在,则Bash仅在作为交互式登录shell调用时读取~/.bash_profile 。 终端和iTerm 2打开新shell作为登录shell,因此Bash读取~/.bash_profile但不读取~/.bashrc 。 请参阅http://www.gnu.org/software/bash/manual/html_node/Bash-Startup-File ...
  • mv path/to/your/executable_file /usr/local/bin/your_desied_command 示例mv composer.phar / usr / local / bin / composer mv path/to/your/executable_file /usr/local/bin/your_desied_command Example mv composer.phar /usr/local/bin/composer
  • .bashrc 用于交互式使用 。 如果要在脚本中使用它们,请不要在那里定义函数。 如果要创建包含要在脚本中使用的函数的文件,请将其作为单独的文件,并从脚本(以及.bashrc )中获取该文件。 将函数放在例如~/lib/bash/myfunctions并放入 . ~/lib/bash/myfunctions 在你的脚本中。 .bashrc is for interactive use. Don't define functions there if you're going to use them in ...
  • 当你说“不起作用”时,我认为你的意思是它实际上并没有将别名放在你的交互式shell中。 那是因为这个脚本在子shell中运行。 当您使用.bashrc时,它会在子shell中安装别名。 然后子shell退出,然后返回到交互式shell。 无法从子shell修改父shell的环境。 也就是说,如果此代码是从父shell中的函数运行的,而不是在子shell中运行,那么您将全部设置完毕。 将此函数放在.bashrc中 function addalias { FIRST="$1" shift ...
  • 我认为正在发生的是配置脚本以root(或sudo)身份运行,因此“〜”home位置实际上是/ root而不是默认用户home位置/ home / vagrant。 我可以想到几种方法来解决这个问题: 首先(也可能是最简单的)是明确的.bashrc路径,如: # Vagrantfile Vagrant.configure("2") do |config| ... various cmds to set box and network... $install_user_vars = <