springboot部署到tomcat

1.创建maven工程,添加依赖,pom文件类容如下:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.szcatic</groupId>
  <artifactId>springboot</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>

  <name>springboot</name>
  <url>http://maven.apache.org</url>
    
  	<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.0.RELEASE</version>
    </parent>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
        <!-- junit5运行所需jar包 -->
		<dependency>
		    <groupId>org.junit.jupiter</groupId>
		    <artifactId>junit-jupiter-engine</artifactId>
		    <scope>test</scope>
		</dependency>
		<dependency>
		    <groupId>org.junit.platform</groupId>
		    <artifactId>junit-platform-runner</artifactId>
		    <scope>test</scope>
		</dependency>
    </dependencies>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <!-- 指定springboot入口类 -->
    	<start-class>com.szcatic.Application</start-class>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
	                <source>1.8</source>
	                <target>1.8</target>
	            </configuration>
            </plugin>
        </plugins>
    </build>
</project>

此处注意<start-class>com.szcatic.Application</start-class> 

2.创建应用程序入口类Application.java

package com.szcatic;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@RestController
public class Application extends SpringBootServletInitializer {
	
	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
		return application.sources(Application.class);
	}
	
	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}
	
	@RequestMapping("/hello")
    public String getHello() {
		return "Hello World";
    }
	
}

3.添加项目到tomcat服务

4.启动tomcat服务,控制台类容如下

十一月 20, 2018 2:13:22 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server version:        Apache Tomcat/9.0.8
十一月 20, 2018 2:13:22 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server built:          Apr 27 2018 19:32:00 UTC
十一月 20, 2018 2:13:22 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server number:         9.0.8.0
十一月 20, 2018 2:13:22 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Name:               Windows 10
十一月 20, 2018 2:13:22 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Version:            10.0
十一月 20, 2018 2:13:22 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Architecture:          amd64
十一月 20, 2018 2:13:22 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Java Home:             E:\JDK\jdk1.8.0_171\jre
十一月 20, 2018 2:13:22 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Version:           1.8.0_171-b11
十一月 20, 2018 2:13:22 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Vendor:            Oracle Corporation
十一月 20, 2018 2:13:22 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_BASE:         E:\Tomcat\apache-tomcat-9.0.8
十一月 20, 2018 2:13:22 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_HOME:         E:\Tomcat\apache-tomcat-9.0.8
十一月 20, 2018 2:13:22 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:65131
十一月 20, 2018 2:13:22 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.base=E:\Tomcat\apache-tomcat-9.0.8
十一月 20, 2018 2:13:22 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.home=E:\Tomcat\apache-tomcat-9.0.8
十一月 20, 2018 2:13:22 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dwtp.deploy=F:\workspace4.7
十一月 20, 2018 2:13:22 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.endorsed.dirs=E:\Tomcat\apache-tomcat-9.0.8\endorsed
十一月 20, 2018 2:13:22 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dfile.encoding=UTF-8
十一月 20, 2018 2:13:22 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: Loaded APR based Apache Tomcat Native library [1.2.16] using APR version [1.6.3].
十一月 20, 2018 2:13:22 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
十一月 20, 2018 2:13:22 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
十一月 20, 2018 2:13:23 下午 org.apache.catalina.core.AprLifecycleListener initializeSSL
信息: OpenSSL successfully initialized [OpenSSL 1.0.2m  2 Nov 2017]
十一月 20, 2018 2:13:23 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-nio-8080"]
十一月 20, 2018 2:13:24 下午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
信息: Using a shared selector for servlet write/read
十一月 20, 2018 2:13:24 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["ajp-nio-8009"]
十一月 20, 2018 2:13:24 下午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
信息: Using a shared selector for servlet write/read
十一月 20, 2018 2:13:24 下午 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 3555 ms
十一月 20, 2018 2:13:24 下午 org.apache.catalina.core.StandardService startInternal
信息: Starting service [Catalina]
十一月 20, 2018 2:13:24 下午 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/9.0.8
十一月 20, 2018 2:13:24 下午 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying deployment descriptor [E:\Tomcat\apache-tomcat-9.0.8\conf\Catalina\localhost\springboot.xml]
十一月 20, 2018 2:13:24 下午 org.apache.catalina.startup.HostConfig deployDescriptor
警告: The path attribute with value [/springboot] in deployment descriptor [E:\Tomcat\apache-tomcat-9.0.8\conf\Catalina\localhost\springboot.xml] has been ignored
十一月 20, 2018 2:13:24 下午 org.apache.catalina.startup.SetContextPropertiesRule begin
警告: [SetContextPropertiesRule]{Context} Setting property 'source' to 'org.eclipse.jst.jee.server:springboot' did not find a matching property.
十一月 20, 2018 2:13:29 下午 org.apache.jasper.servlet.TldScanner scanJars
信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
十一月 20, 2018 2:13:29 下午 org.apache.catalina.core.ApplicationContext log
信息: 1 Spring WebApplicationInitializers detected on classpath

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.0.RELEASE)

2018-11-20 14:13:31.235  INFO 9968 --- [           main] com.szcatic.Application                  : Starting Application on zsx with PID 9968 (F:\workspace4.7\springboot\target\classes started by admin in E:\eclipse)
2018-11-20 14:13:31.245  INFO 9968 --- [           main] com.szcatic.Application                  : No active profile set, falling back to default profiles: default
2018-11-20 14:13:33.411  INFO 9968 --- [           main] o.a.c.c.C.[.[localhost].[/springboot]    : Initializing Spring embedded WebApplicationContext
2018-11-20 14:13:33.411  INFO 9968 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2012 ms
2018-11-20 14:13:33.991  INFO 9968 --- [           main] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
2018-11-20 14:13:34.052  INFO 9968 --- [           main] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-11-20 14:13:34.052  INFO 9968 --- [           main] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'errorPageFilter' to: [/*]
2018-11-20 14:13:34.052  INFO 9968 --- [           main] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-11-20 14:13:34.052  INFO 9968 --- [           main] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'formContentFilter' to: [/*]
2018-11-20 14:13:34.052  INFO 9968 --- [           main] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2018-11-20 14:13:34.563  INFO 9968 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2018-11-20 14:13:35.010  INFO 9968 --- [           main] com.szcatic.Application                  : Started Application in 4.9 seconds (JVM running for 15.165)
2018-11-20 14:13:35.071  INFO 9968 --- [           main] org.apache.catalina.startup.HostConfig   : Deployment of deployment descriptor [E:\Tomcat\apache-tomcat-9.0.8\conf\Catalina\localhost\springboot.xml] has finished in [10,763] ms
2018-11-20 14:13:35.120  INFO 9968 --- [           main] org.apache.catalina.startup.HostConfig   : Deploying web application archive [E:\Tomcat\apache-tomcat-9.0.8\webapps\axis2.war]
2018-11-20 14:13:40.961  INFO 9968 --- [           main] org.apache.jasper.servlet.TldScanner     : At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
[INFO] Clustering has been disabled
[INFO] Deploying module: addressing-1.7.8 - file:/E:/Tomcat/apache-tomcat-9.0.8/webapps/axis2/WEB-INF/modules/addressing-1.7.8.mar
[INFO] Deploying module: jaxws-1.7.8 - file:/E:/Tomcat/apache-tomcat-9.0.8/webapps/axis2/WEB-INF/modules/axis2-jaxws-mar-1.7.8.mar
[INFO] Deploying module: metadataExchange-1.7.8 - file:/E:/Tomcat/apache-tomcat-9.0.8/webapps/axis2/WEB-INF/modules/mex-1.7.8.mar
[INFO] Deploying module: mtompolicy-1.7.8 - file:/E:/Tomcat/apache-tomcat-9.0.8/webapps/axis2/WEB-INF/modules/mtompolicy-1.7.8.mar
[INFO] Deploying module: ping-1.7.8 - file:/E:/Tomcat/apache-tomcat-9.0.8/webapps/axis2/WEB-INF/modules/ping-1.7.8.mar
[INFO] Deploying module: script-1.7.8 - file:/E:/Tomcat/apache-tomcat-9.0.8/webapps/axis2/WEB-INF/modules/scripting-1.7.8.mar
[INFO] Deploying module: soapmonitor-1.7.8 - file:/E:/Tomcat/apache-tomcat-9.0.8/webapps/axis2/WEB-INF/modules/soapmonitor-1.7.8.mar
[INFO] Deploying Web service: version-1.7.8.aar - file:/E:/Tomcat/apache-tomcat-9.0.8/webapps/axis2/WEB-INF/services/version-1.7.8.aar
[INFO] Deploying pojo: ComplexTypeServices - E:\Tomcat\apache-tomcat-9.0.8\webapps\axis2\WEB-INF\pojo\ComplexTypeServices.class
[INFO] Deploying pojo: SimpleService - E:\Tomcat\apache-tomcat-9.0.8\webapps\axis2\WEB-INF\pojo\SimpleService.class
2018-11-20 14:13:42.138  INFO 9968 --- [           main] org.apache.catalina.startup.HostConfig   : Deployment of web application archive [E:\Tomcat\apache-tomcat-9.0.8\webapps\axis2.war] has finished in [7,018] ms
2018-11-20 14:13:42.139  INFO 9968 --- [           main] org.apache.catalina.startup.HostConfig   : Deploying web application directory [E:\Tomcat\apache-tomcat-9.0.8\webapps\docs]
2018-11-20 14:13:43.480  INFO 9968 --- [           main] org.apache.jasper.servlet.TldScanner     : At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
2018-11-20 14:13:43.485  INFO 9968 --- [           main] org.apache.catalina.startup.HostConfig   : Deployment of web application directory [E:\Tomcat\apache-tomcat-9.0.8\webapps\docs] has finished in [1,346] ms
2018-11-20 14:13:43.485  INFO 9968 --- [           main] org.apache.catalina.startup.HostConfig   : Deploying web application directory [E:\Tomcat\apache-tomcat-9.0.8\webapps\examples]
2018-11-20 14:13:45.298  INFO 9968 --- [           main] org.apache.jasper.servlet.TldScanner     : At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
2018-11-20 14:13:45.380  INFO 9968 --- [           main] o.a.c.c.C.[.[localhost].[/examples]      : ContextListener: contextInitialized()
2018-11-20 14:13:45.381  INFO 9968 --- [           main] o.a.c.c.C.[.[localhost].[/examples]      : SessionListener: contextInitialized()
2018-11-20 14:13:45.383  INFO 9968 --- [           main] o.a.c.c.C.[.[localhost].[/examples]      : ContextListener: attributeAdded('StockTicker', 'async.Stockticker@30e338ff')
2018-11-20 14:13:45.398  INFO 9968 --- [           main] org.apache.catalina.startup.HostConfig   : Deployment of web application directory [E:\Tomcat\apache-tomcat-9.0.8\webapps\examples] has finished in [1,913] ms
2018-11-20 14:13:45.399  INFO 9968 --- [           main] org.apache.catalina.startup.HostConfig   : Deploying web application directory [E:\Tomcat\apache-tomcat-9.0.8\webapps\host-manager]
2018-11-20 14:13:46.841  INFO 9968 --- [           main] org.apache.jasper.servlet.TldScanner     : At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
2018-11-20 14:13:46.862  INFO 9968 --- [           main] org.apache.catalina.startup.HostConfig   : Deployment of web application directory [E:\Tomcat\apache-tomcat-9.0.8\webapps\host-manager] has finished in [1,464] ms
2018-11-20 14:13:46.863  INFO 9968 --- [           main] org.apache.catalina.startup.HostConfig   : Deploying web application directory [E:\Tomcat\apache-tomcat-9.0.8\webapps\manager]
2018-11-20 14:13:48.156  INFO 9968 --- [           main] org.apache.jasper.servlet.TldScanner     : At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
2018-11-20 14:13:48.163  INFO 9968 --- [           main] org.apache.catalina.startup.HostConfig   : Deployment of web application directory [E:\Tomcat\apache-tomcat-9.0.8\webapps\manager] has finished in [1,299] ms
2018-11-20 14:13:48.163  INFO 9968 --- [           main] org.apache.catalina.startup.HostConfig   : Deploying web application directory [E:\Tomcat\apache-tomcat-9.0.8\webapps\ROOT]
2018-11-20 14:13:49.402  INFO 9968 --- [           main] org.apache.jasper.servlet.TldScanner     : At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
2018-11-20 14:13:49.407  INFO 9968 --- [           main] org.apache.catalina.startup.HostConfig   : Deployment of web application directory [E:\Tomcat\apache-tomcat-9.0.8\webapps\ROOT] has finished in [1,244] ms
2018-11-20 14:13:49.507  INFO 9968 --- [           main] org.apache.coyote.ajp.AjpNioProtocol     : Starting ProtocolHandler ["ajp-nio-8009"]
2018-11-20 14:13:49.519  INFO 9968 --- [           main] org.apache.catalina.startup.Catalina     : Server startup in 25313 ms

5.打开浏览器,输入网址http://localhost:8080/springboot/hello,显示如下,表示部署到tomcat成功

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值