Spring Boot Traditional Deployent进入Tomcat 8

时间:2015-10-12 15:21:44

标签: spring spring-mvc spring-boot

我将Spring Boot应用程序作为Spring BootApp运行时运行良好。它加载spring-context并且可以在启动过程中看到beans.xml中定义的类。但是,我按照Deploying Spring Boot Applications链接将它们部署到TOMCAT 8服务器中。它没有部署应用程序。似乎无法找到春天的背景。附上我的Application.java,pom.xml并输出我看到的如果将其作为传统战争运行。

Application.java

package com.vti;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.ImportResource;




@Configuration
@ComponentScan("com.vti")
@Import(XMLImportingConfiguration.class)
@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class })
@EnableCaching
@SpringApplicationConfiguration
@SpringBootApplication
public class Application extends SpringBootServletInitializer {

    public static void main(String[] args) {
        SpringApplication.run(Application.class,args);
    }

    @Override
     protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }

    @Bean
    public CacheManager cacheManager(){
        String[] cacheNames = {"mapRouteParams", "appUrls"};
        return new ConcurrentMapCacheManager(cacheNames);
    }

}

@Configuration
@ImportResource("classpath:spring/beans.xml")
class XMLImportingConfiguration {
}

的pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.vti</groupId>
    <artifactId>ivr-callcenter-common-services</artifactId>
    <version>1.0-SNAPSHOT</version>
    <name>VZT CallCenter Framework</name>
    <url>http://maven.apache.org</url>

    <properties>
        <jaxb-api.version>2.1</jaxb-api.version>
        <spring-ws-core.version>2.2.0.RELEASE</spring-ws-core.version>
        <commons-io.version>2.4</commons-io.version>
        <spring-ws-core-tiger.version>1.5.10</spring-ws-core-tiger.version>
        <spring-oxm-tiger.version>1.5.10</spring-oxm-tiger.version>
        <skipTests>true</skipTests>
        <java.version>1.8</java.version>
        <start-class>com.vti.Application</start-class>
    </properties>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.2.6.RELEASE</version>
    </parent>

    <repositories>
        <repository>
            <id>verizontelematics</id>
            <url>http://atlvopst01/maven2</url>
        </repository>
    </repositories>

    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
        </dependency>


        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-log4j</artifactId>
        </dependency>

        <dependency>
            <groupId>com.sun.xml.messaging.saaj</groupId>
            <artifactId>saaj-impl</artifactId>
            <version>1.3.4</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-oxm</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>commons-lang</groupId>
                    <artifactId>commons-lang</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.springframework.ws</groupId>
            <artifactId>spring-oxm-tiger</artifactId>
            <version>${spring-oxm-tiger.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.ws</groupId>
            <artifactId>spring-ws-core-tiger</artifactId>
            <version>${spring-ws-core-tiger.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
        </dependency>


        <!-- Spring AOP -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
        </dependency>

        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
        </dependency>

        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
        </dependency>




        <!-- JAXB API for generating the client classes for the WSDL -->

        <dependency>
            <groupId>javax.xml</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>${jaxb-api.version}</version>
        </dependency>

        <!-- JAVA BeanUtils Dependencies -->

        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
        </dependency>

        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
            <version>2.10.4</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-batch</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.ws</groupId>
            <artifactId>spring-ws-security</artifactId>
        </dependency>

        <!-- SPRING SECURITY -->
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.ws.security</groupId>
            <artifactId>wss4j</artifactId>
            <version>1.6.18</version>
        </dependency>


        <!-- Oracle Drivers -->

        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc14</artifactId>
            <version>10.2.0.2.0</version>
        </dependency>

        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
        </dependency>

    </dependencies>
    <build>
        <finalName>VZTCallCenterFramework</finalName>

        <sourceDirectory>.</sourceDirectory>
        <plugins>
            <!-- <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> 
                <configuration> <includes> <include>src/main/java/**/*.java</include> <include>src/main/generated/**/*.java</include> 
                </includes> </configuration> </plugin> -->
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <jvmArguments> -Xdebug </jvmArguments>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <packaging>war</packaging>
</project>

输出我在服务器上运行时看到了

Oct 12, 2015 11:00:15 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:ivr-callcenter-common-services' did not find a matching property.
Oct 12, 2015 11:00:15 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version:        Apache Tomcat/8.0.26
Oct 12, 2015 11:00:15 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built:          Aug 18 2015 11:38:37 UTC
Oct 12, 2015 11:00:15 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number:         8.0.26.0
Oct 12, 2015 11:00:15 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name:               Windows 7
Oct 12, 2015 11:00:15 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version:            6.1
Oct 12, 2015 11:00:15 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture:          amd64
Oct 12, 2015 11:00:15 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home:             C:\Java\jdk1.8.0_60\jre
Oct 12, 2015 11:00:15 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version:           1.8.0_60-b27
Oct 12, 2015 11:00:15 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor:            Oracle Corporation
Oct 12, 2015 11:00:15 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE:         C:\Users\v579424\Documents\workspace-sts-3.7.0.RELEASE\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
Oct 12, 2015 11:00:15 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME:         C:\servers\apache-tomcat\apache-tomcat-8.0.26-windows-x64\apache-tomcat-8.0.26
Oct 12, 2015 11:00:15 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dspring.profiles.active=dev
Oct 12, 2015 11:00:15 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=C:\Users\v579424\Documents\workspace-sts-3.7.0.RELEASE\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
Oct 12, 2015 11:00:15 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=C:\servers\apache-tomcat\apache-tomcat-8.0.26-windows-x64\apache-tomcat-8.0.26
Oct 12, 2015 11:00:15 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=C:\Users\v579424\Documents\workspace-sts-3.7.0.RELEASE\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
Oct 12, 2015 11:00:15 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=C:\servers\apache-tomcat\apache-tomcat-8.0.26-windows-x64\apache-tomcat-8.0.26\endorsed
Oct 12, 2015 11:00:15 AM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=Cp1252
Oct 12, 2015 11:00:15 AM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Java\jdk1.8.0_60\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Java/jdk1.8.0_60/bin/../jre/bin/server;C:/Java/jdk1.8.0_60/bin/../jre/bin;C:/Java/jdk1.8.0_60/bin/../jre/lib/amd64;c:\Program Files (x86)\Intel\iCLS Client\;c:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;c:\Program Files\ThinkPad\Bluetooth Software\;c:\Program Files\ThinkPad\Bluetooth Software\syswow64;;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;c:\Program Files (x86)\Enterprise Vault\EVClient\x64\;C:\program files\IDM Computer Solutions\UltraEdit;C:\maven\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\cygwin64\bin;C:\Amazon\ec2-api-tools\bin;C:\Amazon\AWSCLI\;C:\Program Files\VanDyke Software\SecureFX\;C:\Java\jdk1.8.0_60\bin;C:\Java\jdk1.7.0_79\bin;C:\database\mysql\bin;C:\Program Files (x86)\IDM Computer Solutions\UltraCompare\;C:\IDE\spring-tool-suite-3.7.0.RELEASE-e4.5-win32-x86_64\sts-bundle\sts-3.7.0.RELEASE;;.
Oct 12, 2015 11:00:15 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
Oct 12, 2015 11:00:15 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Oct 12, 2015 11:00:15 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-nio-8009"]
Oct 12, 2015 11:00:15 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Oct 12, 2015 11:00:15 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1540 ms
Oct 12, 2015 11:00:15 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Oct 12, 2015 11:00:15 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.0.26
Oct 12, 2015 11:00:16 AM org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [205] milliseconds.
Oct 12, 2015 11:00:18 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
Oct 12, 2015 11:00:18 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-nio-8009"]
Oct 12, 2015 11:00:18 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2832 ms

1 个答案:

答案 0 :(得分:0)

根据Deinum的评论,我修改了我的pom以使用spring-boot-starter工件,现在能够在servlet容器中运行和部署。

<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.vti</groupId>
    <artifactId>ivr-callcenter-common-services</artifactId>
    <version>1.0-SNAPSHOT</version>
    <name>VZT CallCenter Framework</name>
    <url>http://maven.apache.org</url>

    <properties>
        <skipTests>true</skipTests>
        <java.version>1.8</java.version>
        <start-class>com.vti.Application</start-class>
    </properties>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.2.6.RELEASE</version>
    </parent>

    <repositories>
        <repository>
            <id>verizontelematics</id>
            <url>http://atlvopst01/maven2</url>
        </repository>
    </repositories>

    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
        </dependency>


        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-log4j</artifactId>
        </dependency>


        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-ws</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-batch</artifactId>
        </dependency>


        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>


        <dependency>
            <groupId>com.sun.xml.messaging.saaj</groupId>
            <artifactId>saaj-impl</artifactId>
            <version>1.3.4</version>
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
        </dependency>



        <!-- JAVA BeanUtils Dependencies -->

        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
        </dependency>


        <dependency>
            <groupId>org.springframework.ws</groupId>
            <artifactId>spring-ws-security</artifactId>
        </dependency>

        <!-- SPRING SECURITY -->
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.ws.security</groupId>
            <artifactId>wss4j</artifactId>
            <version>1.6.18</version>
        </dependency>


        <!-- Oracle Drivers -->

        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc14</artifactId>
            <version>10.2.0.2.0</version>
        </dependency>

        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
        </dependency>

    </dependencies>
    <build>
        <sourceDirectory>.</sourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <includes>
                        <include>src/main/java/**/*.java</include>
                        <include>src/main/generated/**/*.java</include>
                    </includes>
                </configuration>
            </plugin>
            <!-- <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> 
                <configuration> <includes> <include>src/main/java/**/*.java</include> <include>src/main/generated/**/*.java</include> 
                </includes> <jvmArguments> -Xdebug </jvmArguments> </configuration> </plugin> -->
        </plugins>
    </build>
    <packaging>war</packaging>
</project>