使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件
Mybatis属于半自动ORM,在使用这个框架中,工作量最大的就是书写Mapping的映射文件,由于手动书写很容易出错,我们可以利用Mybatis-Generator来帮我们自动生成文件。 1、相关文件 关于Mybatis-Generator的下载可以到这个地址:https://github.com/mybatis/generator/releases 由于我使用的是Mysql数据库,这里需要在准备一个连接mysql数据库的驱动jar包 以下是相关文件截图: 和Hibernate逆向生成一样,这里也需要一个配置文件: generatorConfig.xml
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"> <generatorConfiguration> <!--数据库驱动--> <classPathEntry location="mysql-connector-java-5.0.8-bin.jar"/> <context id="DB2Tables" targetRuntime="MyBatis3"> <commentGenerator> <property name="suppressDate" value="true"/> <property name="suppressAllComments" value="true"/> </commentGenerator> <!--数据库链接地址账号密码--> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost/mymessages" userId="root" password="root"> </jdbcConnection> <javaTypeResolver> <property name="forceBigDecimals" value="false"/> </javaTypeResolver> <!--生成Model类存放位置--> <javaModelGenerator targetPackage="lcw.model" targetProject="src"> <property name="enableSubPackages" value="true"/> <property name="trimStrings" value="true"/> </javaModelGenerator> <!--生成映射文件存放位置--> <sqlMapGenerator targetPackage="lcw.mapping" targetProject="src"> <property name="enableSubPackages" value="true"/> </sqlMapGenerator> <!--生成Dao类存放位置--> <javaClientGenerator type="XMLMAPPER" targetPackage="lcw.dao" targetProject="src"> <property name="enableSubPackages" value="true"/> </javaClientGenerator> <!--生成对应表及类名--> <table tableName="message" domainObjectName="Messgae" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table> </context> </generatorConfiguration> |
需要修改文件配置的地方我都已经把注释标注出来了,这里的相关路径(如数据库驱动包,生成对应的相关文件位置可以自定义)不能带有中文。 上面配置文件中的:
|
1 |
<table tableName="message" domainObjectName="Messgae" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table> |
tableName和domainObjectName为必选项,分别代表数据库表名和生成的实力类名,其余的可以自定义去选择(一般情况下均为false)。 生成语句文件:
|
1 |
java -jar mybatis-generator-core-1.3.2.jar -configfile generatorConfig.xml -overwrite |
2、使用方法 在该目录按住Shift键,右键鼠标选择"在此处打开命令窗口",复制粘贴生成语句的文件代码即可。 看下效果图: 生成相关代码: Message.java
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
package lcw.model; public class Messgae { private Integer id; private String title; private String describe; private String content; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title == null ? null : title.trim(); } public String getDescribe() { return describe; } public void setDescribe(String describe) { this.describe = describe == null ? null : describe.trim(); } public String getContent() { return content; } public void setContent(String content) { this.content = content == null ? null : content.trim(); } } |
MessgaeMapper.xml
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <mapper namespace="lcw.dao.MessgaeMapper" > <resultMap id="BaseResultMap" type="lcw.model.Messgae" > <id column="id" property="id" jdbcType="INTEGER" /> <result column="title" property="title" jdbcType="VARCHAR" /> <result column="describe" property="describe" jdbcType="VARCHAR" /> <result column="content" property="content" jdbcType="VARCHAR" /> </resultMap> <sql id="Base_Column_List" > id, title, describe, content </sql> <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" > select <include refid="Base_Column_List" /> from message where id = #{id,jdbcType=INTEGER} </select> <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" > delete from message where id = #{id,jdbcType=INTEGER} </delete> <insert id="insert" parameterType="lcw.model.Messgae" > insert into message (id, title, describe, content) values (#{id,jdbcType=INTEGER}, #{title,jdbcType=VARCHAR}, #{describe,jdbcType=VARCHAR}, #{content,jdbcType=VARCHAR}) </insert> <insert id="insertSelective" parameterType="lcw.model.Messgae" > insert into message <trim prefix="(" suffix=")" suffixOverrides="," > <if test="id != null" > id, </if> <if test="title != null" > title, </if> <if test="describe != null" > describe, </if> <if test="content != null" > content, </if> </trim> <trim prefix="values (" suffix=")" suffixOverrides="," > <if test="id != null" > #{id,jdbcType=INTEGER}, </if> <if test="title != null" > #{title,jdbcType=VARCHAR}, </if> <if test="describe != null" > #{describe,jdbcType=VARCHAR}, </if> <if test="content != null" > #{content,jdbcType=VARCHAR}, </if> </trim> </insert> <update id="updateByPrimaryKeySelective" parameterType="lcw.model.Messgae" > update message <set > <if test="title != null" > title = #{title,jdbcType=VARCHAR}, </if> <if test="describe != null" > describe = #{describe,jdbcType=VARCHAR}, </if> <if test="content != null" > content = #{content,jdbcType=VARCHAR}, </if> </set> where id = #{id,jdbcType=INTEGER} </update> <update id="updateByPrimaryKey" parameterType="lcw.model.Messgae" > update message set title = #{title,jdbcType=VARCHAR}, describe = #{describe,jdbcType=VARCHAR}, content = #{content,jdbcType=VARCHAR} where id = #{id,jdbcType=INTEGER} </update> </mapper> |
MessgaeMapper.java
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
package lcw.dao; import lcw.model.Messgae; public interface MessgaeMapper { int deleteByPrimaryKey(Integer id); int insert(Messgae record); int insertSelective(Messgae record); Messgae selectByPrimaryKey(Integer id); int updateByPrimaryKeySelective(Messgae record); int updateByPrimaryKey(Messgae record); } |
from:https://www.cnblogs.com/zhujiabin/p/4990762.html
View DetailsJS更随机的随机数
一.问题背景 一个二维平面上有一群NPC,每一回合可以随机向上/下/左/右任一方向走1步,有单位碰撞体积(NPC位置不能重合) 规则就这么简单,初始情况下这群NPC是被人工均匀分布在二维平面上的,运行N个回合后发现所有NPC都集中在了左下角。。怎么会这样,说好的随机呢? 二.分析 现有的实现是这样的: 根据NPC的当前位置判断得到可以去的位置,把结果存放在一维数组arr里P.S.上/下/左/右最多4个点(周围空荡荡的),最少0个点(被围起来了) 生成[0, arr.length – 1]内的一个随机数,作为目标位置索引值index
|
1 2 3 4 5 |
// 生成随机数[min, max] w.Util.rand = function(min, max) { return Math.round(Math.random() * (max - min) + min); } |
控制NPC移动到arr[index]的位置 逻辑应该是没有问题的,可是为什么运行结果是NPC都跑到左下角开会去了呢?等等,为什么是左下而不是其它角角? 因为实现第一步的时候是按照上 -> 下 -> 左 -> 右的顺序判断的,最后都去了左下角,说明向上和向右的概率太小了(生成随机数的函数rand是没问题的,确实能得到[min, max]的数) 问题的根源是Math.random()不给力,生成[0, 1)之间的小数,取到0和靠近1的值概率很小,所以rand()函数生成的随机数取到min和mix的概率也很小,向上/向右的可能性也就小了 三.解决方案 既然取到min和max的概率很小,中间概率比较均匀,那好办,切掉这两个值就好了。具体实现如下:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
function randEx(min, max) { var num; var maxEx = max + 2; // 扩大范围到[min, max + 2],引入两个多余值替换min/max do{ num = Math.round(Math.random() * (maxEx - min) + min); num--; } while (num < min || num > max); // 范围不对,继续循环 return num; } |
值得一提的是上面的加2减1比较巧妙,能够恰好排除min和max 四.运行结果 JS中Math.random()返回值的概率差异可能比你想象的要大些,在实际应用中是不可接受的 测试代码如下:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
// 生成随机数[min, max] w.Util.rand = function(min, max) { return Math.round(Math.random() * (max - min) + min); } // 生成更随机的随机数[min, max] function randEx(min, max) { var num; var maxEx = max + 2; // 扩大范围到[min, max + 2],引入两个多余值替换min/max do{ num = Math.round(Math.random() * (maxEx - min) + min); num--; } while (num < min || num > max); // 范围不对,继续循环 return num; } function testRand(times, fun) { var arr = [1, 2, 3, 4]; var count = []; var randVal; for (var i = 0; i < times; i++) { // 获取[0, 3]的随机数 randVal = fun(0, arr.length - 1); // 记录次数 if (typeof count[randVal] !== "number") { count[randVal] = 0; } count[randVal]++; } console.log(count); } console.log("100 times"); testRand(100, w.Util.rand); // 之前的实现 testRand(100, randEx); // 改进过的实现 console.log("1000 times"); testRand(1000, w.Util.rand); // 之前的实现 testRand(1000, randEx); // 改进过的实现 console.log("10000 times"); testRand(10000, w.Util.rand); // 之前的实现 testRand(10000, randEx); // 改进过的实现 console.log("100000 times"); testRand(100000, w.Util.rand); // 之前的实现 testRand(100000, randEx); // 改进过的实现 |
后话 理论上Java的Math.random(),C#的next可能也存在这个问题,这里就没有必要验证了,因为randEx函数的思想(加2减1,嫌效果不好还可以加4减2、加6减3……直到满意为止)是通用的 from:https://www.cnblogs.com/ayqy/p/4511565.html?utm_source=tuicool
View DetailsWindows配置多个git用户
Window配置多个Git账户,SSH连接GitHub、GitLab 最新版本GIt配置对应多个Git仓库(不需要添加多个用户名和邮箱): 在本地git上添加一个用户名和邮箱,生成一对公钥和私钥,把公钥加入到各个配置SSH key里面。 1.检查本机是否有ssh key设置,切换到.ssh目录 $ cd ~/.ssh 或cd .ssh 2.配置git用户名和邮箱,配置多个用户时添加 --add 参数 $ git config --global --add user.name "username" $ git config --global --add user.email "email" 3.查看用户名和邮箱 $ git config --list 4.生成github.com,gitlab.com对应的私钥公钥. $ ssh-keygen -t rsa -C "test@qq.com" 注:生成id_rsa私钥公钥时需要命不同文件名,密码可设可不设。 5.添加ssh key到对应的GitHub,GitLab上面 登录GitHub系统;点击右上角账号头像的“▼”→Settings→SSH kyes→Add SSH key。 复制id_rsa.pub的公钥内容到Key填写框内。 $ssh -T git@github.com 测试公钥配置是否成功 6.在.ssh下面建立配置文件,文件名为config的文件且不需要添加文件后缀。 config文件配置内容:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
# 配置github.com Host https://github.com/ HostName https://github.com/ IdentityFile C:/Users/zengsm/.ssh/id_rsa PreferredAuthentications publickey User username1 # 配置git.gitlab.com Host http://gitlab.zsm.com/ HostName http://gitlab.zsm.com/ IdentityFile C:/Users/zengsm/.ssh/id_rsa_gitlab PreferredAuthentications publickey User username2 |
HostName 真实的域名地址 IdentityFile id_rsa的地址 PreferredAuthentications 配置登录时用什么权限认证--可设为publickey,password publickey,keyboard-interactive等 User 配置使用用户名 # 可以通过 ssh-add -l 来确私钥列表 $ ssh-add -l # 可以通过 ssh-add -D 来清空私钥列表 $ ssh-add -D 7.克隆代码:从刚才配置的github上克隆项目: git clone git@配置的别名:用户名/项目名.git (例:git clone git@github.com:username/projectname.git) from:https://www.cnblogs.com/zengming/p/7908171.html
View DetailsSpring Boot(六):如何优雅的使用 Mybatis
这两天启动了一个新项目因为项目组成员一直都使用的是 Mybatis,虽然个人比较喜欢 Jpa 这种极简的模式,但是为了项目保持统一性技术选型还是定了 Mybatis 。到网上找了一下关于 Spring Boot 和 Mybatis 组合的相关资料,各种各样的形式都有,看的人心累,结合了 Mybatis 的官方 Demo 和文档终于找到了最简的两种模式,花了一天时间总结后分享出来。 Orm 框架的本质是简化编程中操作数据库的编码,发展到现在基本上就剩两家了,一个是宣称可以不用写一句 Sql 的 Hibernate,一个是可以灵活调试动态 Sql 的 Mybatis ,两者各有特点,在企业级系统开发中可以根据需求灵活使用。发现一个有趣的现象:传统企业大都喜欢使用 Hibernate ,互联网行业通常使用 Mybatis 。 Hibernate 特点就是所有的 Sql 都用 Java 代码来生成,不用跳出程序去写(看) Sql ,有着编程的完整性,发展到最顶端就是 Spring Data Jpa 这种模式了,基本上根据方法名就可以生成对应的 Sql 了,有不太了解的可以看我的上篇文章Spring Boot(五): Spring Data Jpa 的使用。 Mybatis 初期使用比较麻烦,需要各种配置文件、实体类、Dao 层映射关联、还有一大推其它配置。当然 Mybatis 也发现了这种弊端,初期开发了generator可以根据表结果自动生产实体类、配置文件和 Dao 层代码,可以减轻一部分开发量;后期也进行了大量的优化可以使用注解了,自动管理 Dao 层和配置文件等,发展到最顶端就是今天要讲的这种模式了,mybatis-spring-boot-starter 就是 Spring Boot+ Mybatis 可以完全注解不用配置文件,也可以简单配置轻松上手。 现在想想 Spring Boot 就是牛逼呀,任何东西只要关联到 Spring Boot 都是化繁为简。 mybatis-spring-boot-starter 官方说明:MyBatis Spring-Boot-Starter will help you use MyBatis with Spring Boot 其实就是 Mybatis 看 Spring Boot 这么火热也开发出一套解决方案来凑凑热闹,但这一凑确实解决了很多问题,使用起来确实顺畅了许多。mybatis-spring-boot-starter主要有两种解决方案,一种是使用注解解决一切问题,一种是简化后的老传统。 当然任何模式都需要首先引入mybatis-spring-boot-starter的 Pom 文件,现在最新版本是 2.0.0 […]
View Details.NET Core 中的路径问题
NET Core 应用程序相对于以前的.NET Framework 应用程序在启动运行的方式上有一定的差异,今天就来谈一谈这个获取应用程序启动路径的问题。 1.工作路径 WorkingDirectory 下面的两种方式都可以获取工作路径,结果都是一样的:
|
1 2 3 |
Environment.CurrentDirectory; Directory.GetCurrentDirectory(); |
其实所谓的工作路径就是我们应用程序的启动路径,所以我们平时所说的获取应用程序的启动路径,也是通过上面的方式。 (1)我们通过VS F5直接运行 VS会先编译我们的项目,输出到Debug\对应的sdk版本 目录下,然后以这个目录作为工作路径,启动我们的应用程序。 (2)通过dotnet 命令运行 我们在项目根目录,执行 dotnet run命令: 我们执行 dotnet run命令来启动时,对于程序的工作路径就是执行命令的路径,所以说,获取到的路径变化了。但是我们通过dotnet run命令运行的应用程序文件实际所在的目录也是和上面的目录一样的,即:Debug\对应的sdk版本,我们可以通过代码来测试一下: 新加的代码是获取程序集所在的路径,可以发现也是在 Debug\对应的sdk版本 目录下的。 我们将程序发布到 D:\test 目录下 可以看到,前两种方式获取到的都是执行dotnet命令所在的目录即工作目录,后一种方式是获取到的我们应用程序所在的目录。 2.结论 通过上面的测试,我们可以得出结论,.NET Core 应用程序获取工作路径/启动路径,就是获取的执行dotnet命令时所在的目录,所以当我们在Linux等系统部署时,设置守护进程时,记得一定要将工作路径设置为程序文件所在的目录,不然应用程序获取到的路径将不会是应用程序文件所在的目录,当我们在应用程序里设置了一些相对路径,诸如读取配置文件,写日志(Log4net、NLog),将会与我们的预期不一样。因为相对路径,是默认相对于应用程序的工作路径的。
|
1 2 3 4 5 |
Environment.CurrentDirectory; <span class="hljs-comment">//获取应用程序工作目录</span> Directory.GetCurrentDirectory();<span class="hljs-comment">//获取应用程序工作目录(和上面的方式效果是一样的)</span> Path.GetDirectoryName(<span class="hljs-keyword">typeof</span>(Program).Assembly.Location);<span class="hljs-comment">//获取应用程序所在目录(绝对,不受工作目录影响)</span> |
AppContext.BaseDirectory 也可以获取应用程序所在目录 from:https://www.cnblogs.com/stulzq/p/9220502.html
View Detailsgit命令log与reflog的比较
用git命令,想看到自己的操作记录,则可以使用log与reflog,它两个的区别如下: 1.git log 命令可以显示所有提交过的版本信息 例如 如果感觉太繁琐,可以加上参数 --pretty=oneline,只会显示版本号和提交时的备注信息 2.git reflog 可以查看所有分支的所有操作记录(包括已经被删除的 commit 记录和 reset 的操作) 例如执行 git reset --hard HEAD~1,退回到上一个版本,用git log则是看不出来被删除的commitid,用git reflog则可以看到被删除的commitid,我们就可以买后悔药,恢复到被删除的那个版本。 from:https://blog.csdn.net/u013252047/article/details/80230781
View Details.NET Core 如何使用Session
第一步先注册session: 在Startup.cs文件中的ConfigureServices方法中添加:
|
1 |
services.AddSession(); |
在Startup.cs文件中的Configure方法中加上这一句代码
|
1 |
app.UseSession(); |
第二步从nuget安装Microsoft.AspNetCore.Mvc引用,直接使用自带的方法进行设置和获取session 不过自带的方法设置和获取的session值是byte[]类型的,可以从nuget安装并引用Microsoft.AspNetCore.Http并使用里面的扩展方法
|
1 |
using Microsoft.AspNetCore.Http; |
扩展后的方法为
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
/// <summary> /// 设置Session /// </summary> /// <param name="key">键</param> /// <param name="value">值</param> protected void SetSession(string key, string value) { HttpContext.Session.SetString(key, value); } /// <summary> /// 获取Session /// </summary> /// <param name="key">键</param> /// <returns>返回对应的值</returns> protected string GetSession(string key) { var value = HttpContext.Session.GetString(key); if (string.IsNullOrEmpty(value)) value = string.Empty; return value; } |
下面这个图片里面的方法是自带的操作session的方法 下面这个图片是扩展的方法: from:https://www.cnblogs.com/dawenyang/p/9227713.html
View DetailsASP.NET Core 3中的自定义授权
您有一个Web API,并且想要实现自己的授权逻辑,该怎么做?您需要做四件事。 1. 创建您的自定义授权属性 2. 在控制器上使用自定义授权属性 3. 在自定义请求管道中间件中创建授权逻辑 4. 启动时注册中间件 创建您的自定义授权属性
|
1 2 3 4 5 6 7 8 9 10 |
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false)] public class CustomAuthorizeAttribute : Attribute { public string[] AllowedUserRoles { get; private set; } public CustomAuthorizeAttribute(params string[] allowedUserRoles) { this.AllowedUserRoles = allowedUserRoles; } } |
在控制器上使用自定义授权属性
|
1 2 3 4 5 6 7 8 9 10 11 12 |
[ApiController] [Route("[controller]")] public class WeatherForecastController : ControllerBase { [HttpGet] [CustomAuthorize("Admin", "Supervisor", "Worker")] public string Get() { return "Sunny"; } } |
在自定义请求管道中间件中创建授权逻辑
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
public static class CustomAuthorizationMiddleware { public static async Task Authorize(HttpContext httpContext, Func<dynamic> next) { var endpointMetaData = httpContext.GetEndpoint().Metadata; bool hasCustomAuthorizeAttribute = endpointMetaData.Any(x => x is CustomAuthorizeAttribute); if (!hasCustomAuthorizeAttribute) { await next.Invoke(); return; } CustomAuthorizeAttribute customAuthorizeAttribute = endpointMetaData .FirstOrDefault(x => x is CustomAuthorizeAttribute) as CustomAuthorizeAttribute; // TODO: change authorization logic bool isAuthorized = customAuthorizeAttribute.AllowedUserRoles .Any(allowedRole => httpContext.User.IsInRole(allowedRole)); if (isAuthorized) { await next.Invoke(); return; } httpContext.Response.StatusCode = (int)HttpStatusCode.Unauthorized; await httpContext.Response.WriteAsync("unauthorized"); } } |
启动时注册中间件
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseHttpsRedirection(); app.UseRouting(); app.Use(CustomAuthorizationMiddleware.Authorize); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); } } |
确保在调用app.UseRouting()之后添加中间件。这样可以确保在将路由 信息添加到HttpContext 后执行您的中间件。 from:https://www.cnblogs.com/bisslot/p/12330985.html
View Detailsgradle 淘宝镜像
配置gradle镜像 在 %USERPROFILE%\.gradle下面创建新文件init.gradle,输入下面的内容并保存
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
allprojects{ repositories { def REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content/groups/public/' all { ArtifactRepository repo -> if(repo instanceof MavenArtifactRepository){ def url = repo.url.toString() if (url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('https://jcenter.bintray.com/')) { project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL." remove repo } } } maven { url REPOSITORY_URL } } } |
配置maven镜像 复制E:\maven\apache-maven-3.3.9\conf中的settings.xml到%USERPROFILE%\.m2中,修改mirrors即可。
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
<mirrors> <!-- mirror | Specifies a repository mirror site to use instead of a given repository. The repository that | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used | for inheritance and direct lookup purposes, and must be unique across the set of mirrors. | <mirror> <id>mirrorId</id> <mirrorOf>repositoryId</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://my.repository.com/repo/path</url> </mirror> --> <mirror> <id>alimaven</id> <mirrorOf>central</mirrorOf> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> </mirror> <mirror> <id>jcenter</id> <mirrorOf>central</mirrorOf> <name>jcenter.bintray.com</name> <url>http://jcenter.bintray.com/</url> </mirror> <mirror> <id>repo1</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://repo1.maven.org/maven2/</url> </mirror> <mirror> <id>repo2</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://repo2.maven.org/maven2/</url> </mirror> </mirrors> |
build.gradle 配置
|
1 2 3 4 5 |
repositories { mavenLocal() mavenCentral() maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'} } |
作者:liurongming 链接:https://www.jianshu.com/p/67b547b4e6ae 来源:简书 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
View DetailsLinux查看和编辑文件
例如,要想test.txt文件添加内容"I am a boy",test.txt在当前目录中 方法一:vi编辑法 打开终端,输入vi test.txt 回车,按a或i进入编辑模式,输入 I am a boy,然后按esc键退出编辑模式,输入:wq保存并退出。 方法二:echo命令法 打开终端,输入echo ‘I am a boy’ >> ./test.txt 注:追加单行文本法 方法三:cat命令法 cat >> ./test.txt <<EOF I am a boy EOF 注:结尾的EOF要顶格,成对出现,可以其它字符代替。 方法四:cat编辑法 cat >> ./test.txt (回车后开始编辑输入内容) I am a boy. 按cntl+d组合键结束编辑。 VIM编辑器,可以新建文件也可以修改文件,命令为:vim /usr/local/con.cfg 如果这个文件,以前是没有的,则为新建,则下方有提示为新文件,如果文件已存在,则没有提示。 进入编辑器后,我们先按"I”,即切换到“插入”状态。就可以通过上下左右移动光标,或空格、退格及回车等进行编辑内容了,和WINDOWS是一样的了。 当文本编辑结束之后,通常需要退出编辑器。退出编辑器又分为4种情况:保存退出、正常退出、不保存退出及强制退出。 按键盘左上角的"ESC",左下角的插入状态不见了 然后这时,我们输入“冒号”,即":"(不需双引号),在下方会出现冒号,等待输入命令,如图,我输入的是WQ。功能如下。 W:write,写入 Q:quit,退出 再回车,就保存退出了 其实,保存退出还有二个方法: A:在最后输入命令时,直接输入"x",也是一样的,即X=WQ。 B:最快捷的方法:按了ESC后,直接按shift+zz,或者切换到大写模式按ZZ,就可以保存退出了,即是按2下大写的Z。 可以用查看命令:cat查看其内容:cat /usr/local/con.cfg 正常退出有个前提条件是:打开的文本文件在内容上没有被改动过。 按了ESC后再输入冒号,在输入命令时,直接输入"q", 不保存退出的方法,很多时候打开了文件,或者修改了一些地方,才发现错了,非常需要不保存退出。 先按ESC,再输入冒号,在输入命令时,直接输入"q!" 强制退出。这个实在是不应该做的操作,因为很操蛋! 先按ESC,再按冒号,在输入命令时,直接输入"!" 参考: https://jingyan.baidu.com/article/495ba8410ff14d38b30ede01.html from:https://www.cnblogs.com/bingle/p/9785621.html
View Details