First thanks to two bloggers for sharing
http://lib.csdn.net/article/git/55444?knId=767
https://my.oschina.net/alexnine/blog/540651
Buildscript {ext {springbootversion= ' 1.5.2.RELEASE '} repositories {maven {URL' http://maven.aliyun.com/nexus/content/groups/public/'} jcenter ()} dependencies {classpath ("Org.springframework.boot:spring-boot-gradle-plugin:${springbootversion}")}}group' Com.gzkit 'version' 1.0.1-snapshot 'Apply plugin:' Java 'Apply plugin:' Eclipse '
Apply plugin: ' ECLIPSE-WTP 'Apply plugin:' Org.springframework.boot 'Apply plugin:' War 'Compilejava {options.encoding= ' UTF-8 'Options.compilerargs<< "-xlint:unchecked" << "-xlint:deprecation"}sourcecompatibility= 1.7targetcompatibility= 1.7[Javadoc, Compiletestjava]*.options*.encoding = ' UTF-8 'repositories {mavenlocal () Maven {URL' http://maven.aliyun.com/nexus/content/groups/public/'} jcenter ()}configurations {provided//compile.exclude module: "Spring-boot-starter-tomcat"//compile.exclude group: ' Org.apache.tomcat '//compile.exclude group: ' Org.apache.tomcat.embed 'All*.exclude module: ' spring-boot-starter-logging '}ext {shiroversion= ' 1.3.2 '}dependencies {provided (' Org.springframework.boot:spring-boot-starter-web ') {Exclude module:"Spring-boot-starter-tomcat"} compile (' Org.springframework.boot:spring-boot-starter-freemarker ') Compile (' Org.springframework.boot:spring-boot-starter-undertow ') Compile (' Org.springframework.boot:spring-boot-starter-log4j2 ') Compile (' Org.springframework.boot:spring-boot-starter-mail ') //compile (' Org.springframework.boot:spring-boot-starter-data-redis ')//Spring Session//compile (' org.springframework.session:spring-session ')//Apache ShiroCompile ("Org.apache.shiro:shiro-core: $shiroVersion") Compile ("Org.apache.shiro:shiro-web: $shiroVersion") Compile ("Org.apache.shiro:shiro-spring: $shiroVersion") Compile ("Org.apache.shiro:shiro-ehcache: $shiroVersion") //MyBatis SupportCompile (' org.mybatis.spring.boot:mybatis-spring-boot-starter:1.1.1 ') Compile (' tk.mybatis:mapper-spring-boot-starter:1.1.1 ') //Apache CommonsCompile (' org.apache.commons:commons-lang3:3.4 ') Compile (' org.apache.commons:commons-collections4:4.1 ') //Apache Poi (excel/word)Compile (' org.apache.poi:poi:3.14 ') Compile (' Org.apache.poi:poi-ooxml:3.14 ') //Alibaba DataSourceRuntime (' com.alibaba:druid:1.0.27 ') //mysql JDBC driverRuntime (' Mysql:mysql-connector-java ') //Log4j2 needs disruptor to enable async loggerRuntime (' com.lmax:disruptor:3.3.5 ') //Compile files (' Libs/common-uams-2.2.4.jar ')Testcompile (' Org.springframework.boot:spring-boot-starter-test ')}
Two places to be aware of
The first is the Apply plugin: ' ECLIPSE-WTP ', the plugin used to generate the Eclipseweb project (web-tool-platform)
If not, right-click on tomcat inside the server bar and select Add and Remove ... There are no items to publish, plus after running the removal can also, do not know why, should have been generated Eclipseweb project plug-in (Web-tool-platform)
The second is
The main thing is to add support for the war package, and the second is to change the spring-boot-starter-tomcat to provided. The difference between provided and compile is that the corresponding package will be loaded when the former is being debugged, but the package will not be added to the lib of the war package when it is packaged, and the latter will call the corresponding package in both cases.
Finally, to modify the class that started spring
Public classMonolithicplatformapplicationextendsspringbootservletinitializer{@OverrideprotectedSpringapplicationbuilder Configure (Springapplicationbuilder builder) {//TODO auto-generated Method Stub returnBuilder.sources (monolithicplatformapplication.class); } Public Static voidMain (string[] args) {Springapplication.run (monolithicplatformapplication.class, args); } @Bean PublicEmbeddedservletcontainercustomizer Containercustomizer () {return NewEmbeddedservletcontainercustomizer () {@Override Public voidCustomize (Configurableembeddedservletcontainer container) {//errorpage error401page = new ErrorPage (httpstatus.unauthorized, "/401.html");ErrorPage Error404page =NewErrorPage (Httpstatus.not_found, "/static/404.html"); ErrorPage Error500page=NewErrorPage (Httpstatus.internal_server_error, "/static/500.html"); Container.adderrorpages (Error404page, error500page); } }; }}
Here the Springbootservletinitializer is inherited and the Configure method is rewritten to use the Spring Framework's Servlet3.0 support. and allows us to configure the project to start from the Serclet container.
After the modification is complete, you can start the
Plus a application.yml configuration.
server:undertow:accesslog:enabled:trueDir:target/log pattern:combined compression:enabled:truemin-response-size:1Port:8080session:timeout:1800# in Secondsspring:datasource:url:jdbc:mysql://121.201.97.113:3306/km_lis_new?characterencoding=utf-8&usessl=falseusername:root password:zqit3503 Type:com.alibaba.druid.pool.DruidDataSource # using Druid data source Driver-class-name:com.mysql.jdbc.Driver maxactive:2initialsize:1Redis:host:192.168.1.104#password: Redispassword Port:6379Pool:max-idle:100min-idle:1Max-active:1000Max-wait:-1# Database:0 # Database index used by Thisconnection# Port:6379# Host:192.168.1.104# pool:# Max-active:30# min-idle:0# Max-wait:1500# milliseconds# Max-idle:20# timeout:2000# Connection Timeout in milliseconds Freemarker:check-template-location:truecontent-type:text/HTML Expose-request-attributes:trueExpose-session-attributes:trueRequest-context-attribute:request Template-loader-path=classpath:/templates/Settings:locale:zh_CN Template_update_delay:0Tag_syntax:auto_detect Default_encoding:utf-8Output_encoding:utf-8Url_escaping_charset:utf-8date_format:yyyy-mm-DD Time_format:HH:mm:ss datetime_format:yyyy-mm-DD HH:mm:ss number_format: \#.## classic_compatible:trueTemplate_exception_handler:rethrow # Ignore, Debug, Html_debug, Rethrow whitespace_stripping: trueExpose-spring-macro-helpers:truesuffix:. FTL charset:utf-8Cache:falseMVC:Static-path-pattern:/Static/**messages:basename:i18n/ui_messages mail:host:smtp.qq.com Username: [Email protected] Password:mjevcothmfqybbib #使用QQ邮箱SMTP服务需要生成授权码, not QQ password sendTo: [email protected] Disastertitle: Manually switch disaster recovery Mode Disastercontent: Session sharing item-Send mail function-manually switch disaster recovery mode ~ ~ ~ Normaltitle: Manually toggle Normal Mode normalcontent: Session sharing item-Send mail function-manual cut Change Normal Mode ~ ~ ~ Autotitle: Auto switch run mode AutoContent: Session sharing item-Send mail function-Automatic switch operation mode ~ ~ ~ Properties:mail: Smtp:auth:true Starttls:enable:true Required:truemybatis:config-location:classpath:mybatis-config.xml Mapper-locations:classpath:mapp er/**/*Mapper.xml Type-aliases- Package: com.kmlis.entity
Spring boot + Gradle + Eclipse War Pack release summary