在生成的build.gradle文件中配置: plugins { id 'java' id 'application' id 'war' id 'org.gretty' version '2.2.0' id 'com.gradle.build-scan' version '1.16' id 'org.springframework.boot' version '2.1.2.RELEASE' id "io.spring.dependency-management" version "1.0.6.RELEASE" } //基本配置 group 'com.df' version '1.0-SNAPSHOT' mainClassName = 'com.df.run.JobApplication' sourceCompatibility = 1.8 targetCompatibility = 1.8 //Java compiler options compileJava { options.incremental = true options.fork = true options.failOnError = false options.encoding = "UTF-8" } repositories { jcenter() mavenLocal() mavenCentral() maven { url "https://plugins.gradle.org/m2/" } } configurations { developmentOnly runtimeClasspath { extendsFrom developmentOnly } } dependencies { //spring boot implementation 'org.springframework.boot:spring-boot-parent:2.1.2.RELEASE' implementation 'org.springframework.boot:spring-boot-starter:2.1.2.RELEASE' implementation 'org.springframework.boot:spring-boot-starter-aop:2.1.2.RELEASE' implementation 'org.springframework.boot:spring-boot-starter-data-jdbc:2.1.2.RELEASE' implementation 'org.springframework.boot:spring-boot-starter-data-jpa:2.1.2.RELEASE' implementation 'org.springframework.boot:spring-boot-dependencies:2.1.2.RELEASE' implementation 'org.springframework.boot:spring-boot-test-autoconfigure:2.1.2.RELEASE' implementation 'org.springframework.boot:spring-boot-tools:2.1.2.RELEASE' implementation 'org.springframework.boot:spring-boot-starter-cloud-connectors:2.1.2.RELEASE' implementation 'org.springframework.boot:spring-boot-starter-websocket:2.1.2.RELEASE' implementation 'org.springframework.boot:spring-boot-starter-reactor-netty:2.1.2.RELEASE' implementation 'org.springframework.boot:spring-boot-starter-cache:2.1.2.RELEASE' implementation 'org.springframework.boot:spring-boot-starter-groovy-templates:2.1.2.RELEASE' implementation 'org.springframework.boot:spring-boot-docs:2.1.2.RELEASE' implementation 'org.springframework.boot:spring-boot-starter-actuator:2.1.2.RELEASE' //spring boot监控工具 annotationProcessor "org.springframework.boot:spring-boot-configuration-processor" //配置文件处理器 developmentOnly("org.springframework.boot:spring-boot-devtools") //授权Oauth2模块 //implementation 'org.springframework.boot:spring-boot-starter-security:2.1.2.RELEASE' //implementation 'org.springframework.security.oauth:spring-security-oauth2:2.1.2.RELEASE' //implementation 'org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure:2.1.2.RELEASE' //接口授权oauth2 //implementation 'org.springframework.boot:spring-boot-starter-oauth2-client:2.1.2.RELEASE' //接口授权oauth2 //implementation 'org.springframework.boot:spring-boot-starter-data-redis:2.1.2.RELEASE' //将token存储在redis中 //配置shiro认证 implementation 'com.github.theborakompanioni:thymeleaf-extras-shiro:2.0.0' implementation 'org.apache.shiro:shiro-core:1.4.0' implementation 'org.apache.shiro:shiro-spring:1.4.0' implementation 'org.apache.shiro:shiro-ehcache:1.4.0' implementation 'org.apache.shiro:shiro-web:1.4.0' implementation 'org.apache.shiro:shiro-quartz:1.4.0' //配置hibernate /* implementation ('org.hibernate:hibernate-core:5.2.17.Final') { exclude group: 'org.slf4j',module: 'slf4j-api' //排除某一个库(slf4j)依赖 } implementation 'org.hibernate:hibernate-entitymanager:4.3.11.Final'*/ //配置mysql数据库 implementation 'mysql:mysql-connector-java:8.0.13' //mysql 6.0.5 implementation 'com.zaxxer:HikariCP:3.3.0' //HikariCP高效数据库连接池 implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.2' //mybatis implementation 'com.github.pagehelper:pagehelper-spring-boot-starter:1.2.10' //分页查询pagehelper版本1.2.10对应springboot2.1.0.RELEASE implementation 'com.alibaba:druid-spring-boot-starter:1.1.10' //Web相关 implementation 'org.springframework.boot:spring-boot-starter-web:2.1.2.RELEASE' implementation 'org.springframework.boot:spring-boot-starter-thymeleaf:2.1.2.RELEASE' implementation 'net.sourceforge.nekohtml:nekohtml:1.9.22' providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat' providedCompile 'javax.servlet:javax.servlet-api:3.1.0' //quartz定时器 //implementation 'org.springframework.boot:spring-boot-starter-quartz:2.1.2.RELEASE' //缺点:同一个task,如果前一个还没跑完后面一个就不会触发,不同的task也不能同时运行 implementation 'org.quartz-scheduler:quartz:2.3.0' implementation 'org.quartz-scheduler:quartz-jobs:2.3.0' implementation 'org.springframework:spring-tx:5.1.4.RELEASE' implementation 'org.springframework:spring-context-support:5.1.4.RELEASE' implementation 'org.springframework.boot:spring-boot-starter-amqp:2.1.2.RELEASE' //RabbitMQ compile group: 'c3p0', name: 'c3p0', version: '0.9.1.2' //在quartz定时器默认使用c3p0连接池 compile group: 'org.springframework.boot', name: 'spring-boot-starter-velocity', version: '1.4.7.RELEASE' //velocity compile group: 'org.springframework', name: 'spring-context-support', version: '5.1.4.RELEASE' //compile group: 'org.springframework', name: 'spring-tx', version: '5.1.4.RELEASE' //配置H2数据库 runtime group: 'com.h2database', name: 'h2', version: '1.4.197' //H2内嵌数据库 //其它 implementation 'com.alibaba:fastjson:1.2.54' //阿里fastjson implementation 'commons-io:commons-io:2.6' //commons-io implementation 'com.google.guava:guava:23.0' //guava implementation 'redis.clients:jedis:2.9.0' //implementation 'org.slf4j:slf4j-api:1.7.25' //slf4j implementation 'org.jsoup:jsoup:1.11.3' implementation 'commons-fileupload:commons-fileupload:1.2' implementation 'org.apache.poi:poi-ooxml:3.17' implementation 'com.github.penggle:kaptcha:2.3.2' implementation 'io.springfox:springfox-swagger2:2.7.0' implementation 'io.springfox:springfox-swagger-ui:2.7.0' implementation 'eu.bitwalker:UserAgentUtils:1.19' implementation 'com.github.oshi:oshi-core:3.9.1' components { withModule('org.springframework:spring-beans') { allVariants { withDependencyConstraints { // Need to patch constraints because snakeyaml is an optional dependency it.findAll { it.name == 'snakeyaml' }.each { it.version { strictly '1.19' } } } } } } //hadoop //implementation 'org.apache.hadoop:hadoop-client:2.7.3' //implementation 'org.apache.hadoop:hadoop-common:2.7.3' //implementation 'org.apache.hadoop:hadoop-hdfs:2.7.3' //scala implementation 'org.scala-lang:scala-library:2.11.12' //spark implementation 'org.apache.spark:spark-mllib_2.11:2.4.0' implementation 'org.apache.spark:spark-sql_2.11:2.4.0' implementation 'org.apache.spark:spark-graphx_2.11:2.4.0' implementation 'org.apache.spark:spark-launcher_2.11:2.4.0' implementation 'org.apache.spark:spark-catalyst_2.11:2.4.0' implementation 'org.apache.spark:spark-streaming_2.11:2.4.0' implementation 'org.apache.spark:spark-core_2.11:2.4.0' //单元测试 testCompile 'org.mockito:mockito-core:2.7.19' testCompile group: 'junit', name: 'junit', version: '4.12' testCompile 'org.seleniumhq.selenium:selenium-java:3.3.1' testRuntime 'org.scala-lang.modules:scala-xml_2.11:1.1.0' testImplementation 'org.springframework.boot:spring-boot-starter-test' } //打包 jar { enabled = true version = '0.0.1' manifest { attributes("Implementation-Title": "sparkjob", "Implementation-Version": version) } } //设置启动类 bootJar { mainClassName = 'com.df.run.JobApplication' } // buildScan buildScan { // always accept the terms of service termsOfServiceUrl = 'https://gradle.com/terms-of-service' termsOfServiceAgree = 'yes' // always publish a build scan publishAlways() }