gradle

gradle tasks :查看所有的taske命令

bootJar:打包,讲项目的所有依赖和主工程代码打包,一个可直接执行的一个包,不需要tomcat运行

gradle使用bootjar打包后后,解压出来的三个目录

BOOT-INF:

​ classes:存放java文件编译后的class文件

​ lib:所有的lib依赖包

META-INF:

​ MANIFEST.MF:清单文件,描述当前项目可执行的一些信息

org/

​ springframework/

​ boot/

​ loader/: 打包jar包,没有显现的加入在第三方jiar包中,默认通过网络拉取下载,loader文件中JarLauncher.class文件中设置了jar包运行时的入口和打包 后文件的结构(定义了BOOT-INF,META-INF中放什么数据)

public class JarLauncher extends ExecutableArchiveLauncher {
private static final String DEFAULT_CLASSPATH_INDEX_LOCATION = "BOOT-INF/classpath.idx";
static final EntryFilter NESTED_ARCHIVE_ENTRY_FILTER = (entry) -> {
return entry.isDirectory() ? entry.getName().equals("BOOT-INF/classes/") : entry.getName().startsWith("BOOT-INF/lib/");
}; public JarLauncher() {
} protected JarLauncher(Archive archive) {
super(archive);
} protected ClassPathIndexFile getClassPathIndex(Archive archive) throws IOException {
if (archive instanceof ExplodedArchive) {
String location = this.getClassPathIndexFileLocation(archive);
return ClassPathIndexFile.loadIfPossible(archive.getUrl(), location);
} else {
return super.getClassPathIndex(archive);
}
} private String getClassPathIndexFileLocation(Archive archive) throws IOException {
Manifest manifest = archive.getManifest();
Attributes attributes = manifest != null ? manifest.getMainAttributes() : null;
String location = attributes != null ? attributes.getValue("Spring-Boot-Classpath-Index") : null;
return location != null ? location : "BOOT-INF/classpath.idx";
} protected boolean isPostProcessingClassPathArchives() {
return false;
} protected boolean isSearchCandidate(Entry entry) {
return entry.getName().startsWith("BOOT-INF/");
} protected boolean isNestedArchive(Entry entry) {
return NESTED_ARCHIVE_ENTRY_FILTER.matches(entry);
} public static void main(String[] args) throws Exception {
(new JarLauncher()).launch(args);
}
}

配置文件说明

//相当于plugins{}
//开发语言
apply plugin :"java"
// 打包方式
apply plugin :"war"
//下载idea相关插件
apply plugin: "idea"
//maven的相关插件
apply plugin: "maven" apply plugin: 'org.akhikhl.gretty' //apply from: 'https://raw.github.com/akhikhl/gretty/master/pluginScripts/gretty.plugin' buildscript {
repositories {
mavenCentral()
} dependencies {
classpath 'org.akhikhl.gretty:gretty:2.0.0'
}
} repositories {
mavenCentral()
} if (!project.plugins.findPlugin(org.akhikhl.gretty.GrettyPlugin))
project.apply(plugin: org.akhikhl.gretty.GrettyPlugin) //配置服务器相关属性 tomcat
/*buildscript {
repositories {
mavenCentral()
}
dependencies{
classpath 'org.zkhikhl.gretty:gretty:2.0.0'
}
}
repositories {
mavenCentral()
}
if (!project.plugins.findPlugin(org.akhikhl.gretty.GretyPlugin))
project.apply (plugin: org.akhikhl.gretty.GretyPlugin)
//配置tomcat的属性*/ gretty {
// 端口号
httpPort = 8080
// 项目名
contextPath = '/mygradle'
host = 'localhost'
httpEnabled = true
// servlet的容器
servletContainer = 'tomcat8'
// 热部署
scanInterval = 1
// 检测是否发生修改,修改立刻生效
fastReload = true
// 日志级别
loggingLevel = 'DEBUG'
// 日治在哪里显示,在控制台显示
consoleLogEnabled = true
// ... many more properties //调试配置 监听端口 需要在Run-->Edit-->添加remote-->修改监听端口 默认5005
//
debugPort = 8888
debugSuspend = true
} /*
plugins {
//开发语言
id 'java'
// 打包方式
id 'war'
}*/ group 'com.zhang'
version '1.0-SNAPSHOT'
//指定java的jdk
sourceCompatibility = 1.8
targetCompatibility = 1.8 repositories {
// 依赖下载仓库:这里是maven仓库
mavenCentral()
}
//指定依赖包下载私服
/*dependencies{
repositories {
maven{
url:制定的ip地址
}
}
}*/ //jar包
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
}
//设置项目的各个阶段的编码
tasks.withType(JavaCompile){
options.encoding = "UTF-8"
}
[compileJava,javadoc,compileTestJava]*.options*.encoding ="UTF-8"

gradles理解和文件配置的更多相关文章

  1. 深入浅出Mybatis系列(八)---mapper映射文件配置之select、resultMap

    上篇<深入浅出Mybatis系列(七)---mapper映射文件配置之insert.update.delete>介绍了insert.update.delete的用法,本篇将介绍select ...

  2. Spring、Spring MVC、MyBatis整合文件配置详解

    原文  http://www.cnblogs.com/wxisme/p/4924561.html 主题 MVC模式MyBatisSpring MVC 使用SSM框架做了几个小项目了,感觉还不错是时候总 ...

  3. Spring简单的文件配置

    Spring简单的文件配置 “计应134(实验班) 凌豪” 一.Spring文件配置 spring至关重要的一环就是装配,即配置文件的编写,接下来我按刚才实际过程中一步步简单讲解. 首先,要在web. ...

  4. 深入浅出Mybatis系列(八)---mapper映射文件配置之select、resultMap good

    上篇<深入浅出Mybatis系列(七)---mapper映射文件配置之insert.update.delete>介绍了insert.update.delete的用法,本篇将介绍select ...

  5. 转载 Spring、Spring MVC、MyBatis整合文件配置详解

    Spring.Spring MVC.MyBatis整合文件配置详解   使用SSM框架做了几个小项目了,感觉还不错是时候总结一下了.先总结一下SSM整合的文件配置.其实具体的用法最好还是看官方文档. ...

  6. JavaScript日历控件开发 C# 读取 appconfig文件配置数据库连接字符串,和配置文件 List<T>.ForEach 调用异步方法的意外 ef 增加或者更新的习惯思维 asp.net core导入excel 一个二级联动

    JavaScript日历控件开发   概述 在开篇之前,先附上日历的代码地址和演示地址,代码是本文要分析的代码,演示效果是本文要实现的效果代码地址:https://github.com/aspwebc ...

  7. 深入理解Java中配置环境变量

    深入理解Java中配置环境变量 配置的目的: 本来只在安装JDK的bin目下能运行java.exe,javac.exe,jar.exe,javadoc.exe等Java开发工具包命令,我们现在想让在所 ...

  8. Apache 中httpd.conf文件配置详解(转载)

    httpd.conf文件配置详解   Apache的基本设置主要交由httpd.conf来设定管理,我们要修改Apache的相关设定,主要还是通过修改httpd.cong来实现.下面让我们来看看htt ...

  9. 对vue中 默认的 config/index.js:配置的详细理解 -【以及webpack配置的理解】-config配置的目的都是为了服务webpack的配置,给不同的编译条件提供配置

    当我们需要和后台分离部署的时候,必须配置config/index.js: 用vue-cli 自动构建的目录里面  (环境变量及其基本变量的配置) var path = require('path') ...

随机推荐

  1. C#的TimeSpan

    前言 参考 TimeSpan介绍: https://blog.csdn.net/weixin_41600552/article/details/82220645 微软文档: https://docs. ...

  2. 每日CSS_仿苹果平滑开关按钮

    每日CSS_仿苹果平滑开关按钮 2020_12_24 源码 1. 代码解析 1.1 html 代码解析 <div class="checkbox"> <div c ...

  3. STM32F103的CAN结构体学习

    使用STM32F103的CAN通信就是用这4个结构体函数,把他们理解透了,CAN就好用了 CAN的结构体定义在stm32f10x_can.h里面 /************************** ...

  4. Access denied for user ''@'localhost' to database 'mysql'问题

    Access denied for user ''@'localhost' to database 'mysql'问题 MySQL : Access denied for user ''@'local ...

  5. Flash Player的终章——赠予它的挽歌

    本文由葡萄城技术团队原创并首发 转载请注明出处:葡萄城官网,葡萄城为开发者提供专业的开发工具.解决方案和服务,赋能开发者. 12月28日消息,微软已经确认Windows 10在下一次更新时将自动删除F ...

  6. Linux嵌入式学习-交叉编译mplayer

    http://bbs.gkong.com/archive.aspx?ID=286721

  7. Kubernetes官方java客户端之一:准备

    欢迎访问我的GitHub https://github.com/zq2599/blog_demos 内容:所有原创文章分类汇总及配套源码,涉及Java.Docker.Kubernetes.DevOPS ...

  8. Turtlebot3新手教程:Open-Manipulator机械臂

    *本文针对如何结合turtlebot3和Open-Manipulator机械臂做出讲解 测试在Ubuntu 16.04, Linux Mint 18.1和ROS Kinetic Kame下进行 具体步 ...

  9. BCC和libbpf的转换

    BCC和libbpf的转换 本文讲述如何将基于BCC的BPF应用转换为libbpf + BPF CO-RE.BPF CO-RE可以参见上一篇博文. 为什么是libbpf和BPF CO-RE? 历史上, ...

  10. Solon rpc 之 SocketD 协议 - 消息加密模式

    Solon rpc 之 SocketD 协议系列 Solon rpc 之 SocketD 协议 - 概述 Solon rpc 之 SocketD 协议 - 消息上报模式 Solon rpc 之 Soc ...