设置tomcat自启动服务


在项目开发过程中,以前只是在MyEclipse中配置, 启动, 停止tomcat服务器
如果希望在服务器中自启动 tomcat 服务器, 而不想安装 MyEclipse,
可以使用 Service.bat 将 tomcat 安装到计算机中的服务里面 Services.msc,
就可以使用DOS命令启动或停止 tomcat 服务了.

一般在 tomcat 的 bin 目录下有 service.bat 文件, 如果没有就去下载一个有此文件的tomcat.

01  win + R, cmd, Enter                            -- 打开cmd窗口, 此时工作目录是在C盘
02  d:                                             -- 将目录切换到D盘
03  cd xx\xx\bin                                   -- 目录切换到tomcat的bin目录下
04  service install [ServiceName]                  -- 安装tomcat服务项
05  win + R, services.msc, Enter                   -- 打开服务管理界面,找到tomcat服务项,确定tomcat服务已经安装,并右键查看服务的名称,我的就是tomcat7.
06  win + R, cmd, Enter, net start <ServiceName>   -- 启动tomcat
07  net stop <ServiceName>                         -- 停止tomcat

例如:
========================================================================================
序号 命令行                                        -- 说明
========================================================================================
01   CMD                                           -- 用管理员身份运行
02   CD C:\APP\apache-tomcat-7.0.85\bin            -- 改变路径
03   Service Install BYUser                        -- 安装服务, 服务名为: BYUser, 需要 Service.bat 文件
04   SC Config BYUser Start= Auto                  -- 配置自动模式: 开机自启动
05   Net Start BYUser                              -- 启动服务
06   Service Remove                                -- 删除安装的服务, 安装时无服务名
07   Service Remove BYUser                         -- 删除安装的服务, 安装时有服务名
========================================================================================
另外一种方法可参考如下:
安装服务: 进入安装目录-> bin, 在空白处按住 shift+鼠标右键 -> 在此处运行命令窗口,
将 service.bat 文件拖拽到命令窗口中, 按 enter 键运行,
出现了"Usage: service.bat install/remove [service_name] [/user username]"
提示后, 输入 service.bat install Tomcat
输完然后按 Enter 键, 会显示所调用的环境变量, 即为服务安装成功。
设置服务自启动:
控制面板-> 管理工具 -> 服务(右键 -> 以管理员身份运行), 
找到Apache Tomcat 8.0 tomacat, 设置为自动。


Tomcat不部署项可以启动,部署项目后不写上下文路径的path可以启动,写了就不能了。日志如下。

11-22
十一月 22, 2017 1:51:01 下午 org.apache.catalina.core.StandardContext resourcesStart 严重: Error starting static Resources java.lang.IllegalArgumentException: Document base C:\Excute\Tomcat\apache-tomcat-7.0.57\webapps\pss does not exist or is not a readable directory at org.apache.naming.resources.FileDirContext.setDocBase(FileDirContext.java:136) at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:5110) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5294) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) 十一月 22, 2017 1:51:01 下午 org.apache.catalina.core.ContainerBase startInternal 严重: A child container failed during start java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/pss]] at java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.util.concurrent.FutureTask.get(FutureTask.java:188) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:816) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/pss]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) ... 6 more Caused by: org.apache.catalina.LifecycleException: Error in resourceStart() at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5295) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ... 6 more 十一月 22, 2017 1:51:01 下午 org.apache.catalina.core.ContainerBase startInternal 严重: A child container failed during start java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]] at java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.util.concurrent.FutureTask.get(FutureTask.java:188) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123) at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:300) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:739) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.startup.Catalina.start(Catalina.java:689) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:321) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:455) Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) Caused by: org.apache.catalina.LifecycleException: A child container failed during start at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1131) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:816) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ... 6 more 十一月 22, 2017 1:51:01 下午 org.apache.catalina.startup.Catalina start 严重: The required Server component failed to start so Tomcat is unable to start. org.apache.catalina.LifecycleException: Failed to start component [StandardServer[8005]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) at org.apache.catalina.startup.Catalina.start(Catalina.java:689) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:321) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:455) Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Catalina]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:739) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ... 7 more Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ... 9 more Caused by: org.apache.catalina.LifecycleException: A child container failed during start at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1131) at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:300) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ... 11 more 十一月 22, 2017 1:51:01 下午 org.apache.coyote.AbstractProtocol pause 信息: Pausing ProtocolHandler ["http-apr-8080"] 十一月 22, 2017 1:51:01 下午 org.apache.coyote.AbstractProtocol pa
©️2020 CSDN 皮肤主题: 编程工作室 设计师: CSDN官方博客 返回首页
实付0元
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值