废话不多说

一 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

 

原文地址:http://www.cnblogs.com/hanjun0612/p/16880484.html

1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长! 2. 分享目的仅供大家学习和交流,请务用于商业用途! 3. 如果你也有好源码或者教程,可以到用户中心发布,分享有积分奖励和额外收入! 4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解! 5. 如有链接无法下载、失效或广告,请联系管理员处理! 6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需! 7. 如遇到加密压缩包,默认解压密码为"gltf",如遇到无法解压的请联系管理员! 8. 因为资源和程序源码均为可复制品,所以不支持任何理由的退款兑现,请斟酌后支付下载 声明:如果标题没有注明"已测试"或者"测试可用"等字样的资源源码均未经过站长测试.特别注意没有标注的源码不保证任何可用性