gpt4 book ai didi

hibernate - Java 应用程序作为具有数据库连接的 Windows 服务

转载 作者:行者123 更新时间:2023-11-28 22:32:49 25 4
gpt4 key购买 nike

我正在尝试使用 tomcat 7 将 java 应用程序作为 Windows 服务运行。在此应用程序中,我使用 Hibernate 与 MySql 建立了数据库连接。当我运行 tomcat 时,它停在这一行:

SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory(); 

我在 WEB-INF\lib 目录中有所有必要的 hibernate jar。当从 eclipse 运行这个应用程序时它运行良好。这是 run.bat 文件:

cd "c:\Users\sl300\Project\temp3\build\classes"
temp3.exe //IS//temp3 ^
--Install="c:\Users\sl300\Project\temp3\build\classes\temp3.exe" ^
--Description="My Watcher Service" ^
--Jvm=auto ^
--Classpath="c:\Users\sl300\Project\temp3\build\classes" ^
--StartMode=jvm --StartClass=ServiceControl ^
--StartMethod=windowsService ^
--StartParams=start ^
--StopMode=jvm ^
--StopClass=ServiceControl ^
--StopMethod=windowsService ^
--StopParams=stop ^
--LogPath="c:\Users\sl300\Project\temp3\logs" ^
--StdOutput=auto ^
--StdError=auto
temp3w //MS//

我需要做什么才能完成这项工作?

最佳答案

有关如何将 Tomcat 配置为 Windows 服务的详细手册,请访问 tomcat.apache.org。 .这应该可以解决您的问题。

它在 Windows specific ZIP downloads 中提供只有,而不是通用的。

编辑:这不是答案,但我确实想停止在评论部分聊天:

  1. 为什么您的 temp3.exe 位于文件夹 ...build/classes 中,这对我来说没有意义?
  2. 为什么将其重命名为 temp3.exe

关于hibernate - Java 应用程序作为具有数据库连接的 Windows 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7039170/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com