首页 > 其他分享 >springboot 发布tomcat(zip包)

springboot 发布tomcat(zip包)

时间:2022-11-11 15:15:16浏览次数:36  
标签:zip assembly springboot tomcat boot test org

废话不多说

一 POM

调试时使用tomcat,打包时过滤tomcat包
<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

打包插件
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.0.0</version>
                <configuration>
                    <descriptors>
                        <descriptor>src/main/assembly/assembly.xml</descriptor>
                        <!--对应在src/main/resource包下创建assembly.xml配置文件-->
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

 

二 assembly.xml

具体路径根据上面plugin中来

<assembly>
    <id>test</id>
    <formats>
        <format>zip</format>
    </formats>
    <fileSets>
        <fileSet>  <!--将项目必须的文件打包到zip包根目录下-->
            <directory>${project.build.directory}/${project.build.finalName}</directory>
            <includes>
                <include>**</include>
            </includes>
            <outputDirectory>/</outputDirectory>
        </fileSet>
    </fileSets>

</assembly>

 

三 启动类

增加继承和重写就好了

@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);
    }
}

 

四 打包

mvn clean package

在target目录下出现了war和zip包

打包出来的zip内容:

1 没有META-INF没有主文件

2 WEB-INF中没有web.xml

​编辑

 

解压zip包,修改一下名字:比如我的

kintech.webCamunda-0.0.1-SNAPSHOT-test

改成

kintech.webCamunda

然后把他拷贝到一个文件夹,我拷贝到的是 D:\project  

 

五,设置tomcat的项目启动路径

      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
<!--主要是这句Context docBase -->
    <Context docBase="D:\project\kintech.webCamunda" path="" reloadable="false" />
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />

      </Host>

PS:windows打的是绝对路径

Lunix 打的是 /root/project     ......这样

 

 六 启动tomcat

运行tomcat中的 startup.bat

 

七 访问

如下访问就可以了。

我设置了端口9022,controller也增加了test方法。

http://localhost:9022/api/test/test

 

标签:zip,assembly,springboot,tomcat,boot,test,org
From: https://www.cnblogs.com/hanjun0612/p/16880484.html

相关文章

  • springboot 引入外部包的坑Lookup method resolution failed; nested exception is ja
    手动引入jar包<dependency><groupId>com.allinpay.sdk</groupId><artifactId>top-sdk-java</artifactId><version>1.0.5</......
  • Linux-Centos springboot 部署步骤
    0. 崭新Centos7.9部署springboot一.Java安装1. 查看yum是否安装(如果有安装,则打印详情)rpm-qa|grepyum2.查看java是否安装rpm-qa|grepjava3.查找......
  • 阿里云kafka使用springboot单个项目中同时消费不同topic
    本来是个简单的问题,但是复杂了。两个topic消费方式不一样,一个使用过的是默认方式,不指定partition,另外一个,指定了特殊的partition。报错:11:10:32.888[org.springframework.......
  • springBoot的java工具类
    断言是一个逻辑判断,用于检查不应该发生的情况Assert关键字在JDK1.4中引入,可通过JVM参数-enableassertions开启SpringBoot中提供了Assert断言工具类,通常用......
  • 3:Tomcat部署Web项目-Java Web
    目录​​3.1Web应用程序​​​​3.2部署Web项目​​​​3.3配置虚拟目录​​​​3.4配置Web项目的首页​​3.1Web应用程序一个web应用程序是由一组Servlet,HTML页......
  • 3:SpringBoot-Java Spring
    目录​​3.1SpringBoot介绍​​​​3.2Spring和SpringBoot的区别​​​​3.3系统要求​​​​3.4SpringBootApplication​​3.1SpringBoot介绍SpringBoot的本质是Sprin......
  • 4:SpringBoot-Starter-Java Spring
    目录​​4.1SpringBoot-Starter介绍​​​​4.1Starter原理​​​​4.3Starter依赖引入​​​​4.4Starter配置​​4.1SpringBoot-Starter介绍Starter是SpringBoot的一......
  • 5:SpringBoot-Actuator-Java Spring
    目录​​5.1SpringBoot-Actuator介绍​​​​5.2Endpoints介绍​​​​5.3Actuator原理​​​​5.4Actuator依赖引入​​5.1SpringBoot-Actuator介绍Actuator是Spring......
  • springboot 发布tomcat
    ​废话不多说一下载tomcatApacheTomcat®-ApacheTomcat9SoftwareDownloads 二修改tomcat配置1 conf\server.xml这里我修改了9021端口<Serverport="90......
  • Java MAC环境Intellij2022配置Servlet和Tomcat
    1、下载安装Tomcat官网:https://tomcat.apache.org/download-90.cgi ->download 下载完放入自定义路径,需要记住!这样算下载好了,详细-> https://blog.csdn.net/qq_44......