简体   繁体   English

部署jar Tomcat 8

[英]Deploy jar Tomcat 8

i've not developed for a long time. 我已经很长一段时间没有发展。

Now i'm starting developing again. 现在,我开始重新开发。 I've built spring boot application, but unfortunately after "Maven:Install" in Intellij a copy the file to Tomcat 8, Tomcat don't deploy the app. 我已经构建了Spring Boot应用程序,但是不幸的是,在Intellij中的“ Maven:Install”之后,将文件复制到Tomcat 8,Tomcat没有部署该应用程序。

In server.xml i have autoDeploy="true" 在server.xml中,我有autoDeploy =“ true”

The build section in pom.xml is: pom.xml中的构建部分是:

<build>
    <finalName>ROOT</finalName>
    <plugins>
        <plugin>
            <artifactId>maven-eclipse-plugin</artifactId>
            <version>2.9</version>
            <configuration>
                <additionalProjectnatures>
                    <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
                </additionalProjectnatures>
                <additionalBuildcommands>
                    <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
                </additionalBuildcommands>
                <downloadSources>true</downloadSources>
                <downloadJavadocs>true</downloadJavadocs>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.5.1</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
                <compilerArgument>-Xlint:all</compilerArgument>
                <showWarnings>true</showWarnings>
                <showDeprecation>true</showDeprecation>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.2.1</version>
            <configuration>
                <mainClass>org.test.int1.Main</mainClass>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

Of course Tomcat works fine. 当然,Tomcat工作正常。

In catalina there is no info, that tomcat is trying to deploy - exactly nothing. 在catalina中,没有信息,tomcat正在尝试部署-完全没有。

Could you support me, what i forgot? 你能支持我,我忘记了什么?

if you develop a spring boot application , you don't need to copy file to tomcat. 如果您开发Spring Boot应用程序,则无需将文件复制到tomcat。 You have only to run the generated jar file with: 您只需要使用以下命令运行生成的jar文件:

'java -jar jarFileName.jar' 'java -jar jarFileName.jar'

and will start the application. 并将启动该应用程序。 The tomcat is included in the jar file Tomcat包含在jar文件中

TO be able to deploy your spring boot application as .war file to tomcat server you need the following prerequsites: 为了能够将您的spring boot应用程序作为.war文件部署到tomcat服务器,您需要满足以下先决条件:

  1. add spring-boot-maven plugin to your pom.xml 将spring-boot-maven插件添加到pom.xml

      <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>${springboot.version}</version> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> 
  2. You should make your SpringBootApplication extend SpringBootServletInitializer 您应该使您的SpringBootApplication扩展SpringBootServletInitializer

     @SpringBootApplication public class YourSpringBootApplication extends SpringBootServletInitializer { public static void main(String[] args) { SpringApplication.run(YourSpringBootApplication .class, args); } @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(YourSpringBootApplication .class); } } 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM