java使用tomcat7的maven插件发布到服务器

服务器容器使用tomcat7的maven插件,使用该插件不需要使用tomcat服务器。以下示例均以paycore项目为例。

一、使用tomcat7-maven-plugin

首先在主pom(paycore-parent.pom)里引入maven插件,配置好端口号,示例端口号为8071,如下所示:

pom.xml

<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<port>8071</port>
<uriEncoding>UTF-8</uriEncoding>
<path>/</path>
</configuration>
</plugin>

二、服务器目录约定

服务器目录应遵循:

  1. 测试服务器目录结构和正式环境必须保持一致
  2. 测试服务器发布目录为/webapp
  3. 日志目录统一为/opt/log/webapp/{项目名称}

三、发布应用

进入/webapp目录

[root@convenient ~]# cd /webapp
[root@convenient webapp]#

执行app命令,命令格式为

app {start|stop} {应用名称} {环境名称}

查看应用状态

app status {项目名称}

帮助

app help

以paycore为例启动流程如下

[root@convenient webapp]# app start paycore dev
启动系统:paycore
日志目录:/var/log/webapps/paycore
控制台日志:/var/log/webapps/paycore/console.log
环境变量:dev
请输入paycore项目svn路径:

输入地址https://svn.unknowntech.dev/svn/project/javasns/paycore/branch/paycore-parent

因ssl证书问题需要再确认一下

Error validating server certificate for 'https://svn.unknowntech.dev:443':
- The certificate is not issued by a trusted authority. Use the
fingerprint to validate the certificate manually!
- The certificate hostname does not match.
Certificate information:
- Hostname: WIN-HLK37TUII0U
- Valid: from Thu, 10 Sep 2015 01:50:59 GMT until Sun, 07 Sep 2025 01:50:59 GMT
- Issuer: WIN-HLK37TUII0U
- Fingerprint: 62:a5:6c:b3:7c:60:1d:d2:ea:50:b5:3a:d1:f0:cf:70:67:3f:42:83
(R)eject, accept (t)emporarily or accept (p)ermanently? p

选accept permanently 永久接受

看到这段显示就启动成功了

Nov 13, 2015 2:24:40 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8071"]
Nov 13, 2015 2:24:40 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Tomcat
Nov 13, 2015 2:24:40 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.47
Nov 13, 2015 2:24:50 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Nov 13, 2015 2:24:54 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Nov 13, 2015 2:24:57 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'paycore'
Nov 13, 2015 2:24:59 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8071"]
上一篇:梦想还是要有的-纪念正式成为csdn博客专家暨年中总结


下一篇:MyEclipse开发Web项目发布到Tomcat下的Root目录