To add a tomcat plugin for Gradle, debug your web App

Source: Internet
Author: User
Tags jcenter

Gradle provides a dependency management that does not lose in Maven

Provides a powerful test function to output a beautifully tested report

and provide war plug-ins, debug Web Apps with built-in jetty

Because bloggers have a passion for tomcat, they want to use Tomcat to debug web Apps

Let's use a little bit of code to configure the Tomcat plugin into the project

Implementing a one-click Debug Deployment Web App

Build.gradle file:

Buildscript {repositories {jcenter ()} dependencies {classpath "com.bmuschko:gradle-tomcat-plugin:2.2.3" 
     }}Apply plugin:"Java"Apply plugin:"War"Apply plugin:"Eclipse"Apply plugin: "Com.bmuschko.tomcat"sourcecompatibility= 1.8version= "0.0.1-snapshot"War.basename= "Jblog"Project.webappdirname= "Src/main/webapp"//extended attributes are placed in the internal class of Extext{hibernate_version= "4.3.9.Final"spring_version= "4.2.3.RELEASE"}configurations {provided}sourcesets {main{resources.srcdirs= ["Src/main/java"]//introduce a resource file, and the configuration file will be embedded in the war file when packaged} Main.compileclasspath+=configurations.provided Test.compileclasspath+=configurations.provided Test.runtimeclasspath+=configurations.provided}repositories {mavenlocal () Maven {URL"Http://maven.oschina.net/content/groups/public/"} mavencentral () Jcenter ()}dependencies {compile ("Org.hibernate:hibernate-core:${hibernate_version}",        "Org.hibernate:hibernate-ehcache:${hibernate_version}",        "Org.springframework:spring-core:${spring_version}",        "Org.springframework:spring-beans:${spring_version}",        "Org.springframework:spring-context:${spring_version}",        "Org.springframework:spring-tx:${spring_version}",        "Org.springframework:spring-web:${spring_version}",        "net.sf.ehcache:ehcache:2.9.0",        "Mysql:mysql-connector-java:5.1.37",        "Log4j:log4j:1.2.17",        "Mysql:mysql-connector-java:5.1.37") Testcompile"junit:junit:4.7"provided"Javax.servlet:javax.servlet-api:4.+"def tomcatversion = ' 8.0.27 ' tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatversion}", "Org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatversion}", "Org.apache.tomcat.embed:tomcat-embe D-jasper:${tomcatversion} "}//Note that the following configuration, the new version gradle, will cause eclipse to make frequent errors if you do not use the array additions.Eclipse.classpath.plusConfigurations + =[Configurations.provided]tasks.withtype (javacompile) {options.encoding= "UTF-8"}Tomcatrun.contextpath = '/jblog ' Tomcatrunwar.contextpath = '/jblog '

All the blue fonts above are all the code that needs to be configured

Default port 8080, after you execute the tomcatrun command, you are prompted:

The Server is running at Http://localhost:8080/jblog

This time access to Http://localhost:8080/jblog can be accessed by your app for debugging

Because Tomcat's Gradle plugin is ultra-lightweight, all without any additional functionality, access to http://localhost:8080 is not visible to any Tomcat welcome interface

This seems to be just debugging Web applications, and using the built-in jetty debugging seems to be not much difference, hehe

Related hair, I hate the kind of text not to send pictures of the blog, often make people confused, busy chaos

Project structure

Execute Gradle command

Enter build tomcatrun command (note case), click Run to execute

Terminal output as shown, this time you can access the URL to test our app.

To add a tomcat plugin for Gradle, debug your web App

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.