Eclipse Maven 配置使用国内镜像库

Windows 下因为 Eclipse 自带了 Maven 插件,还算够用就懒得安装 Maven 了。在不使用代理的情况下,用 Maven 的下载库不是一般的慢。Eclipse Maven 的插件怎么配置国内的镜像库呢?其实很简单。 创建 settings.xml 文件 注意两个地方: 1、<localRepository>C:\Users\Lenovo\.m2\repository</localRepository> 本地仓库位置 2、镜像配置,选取的是 aliyun 的 <mirrors> <mirror> <id>alimaven</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> </mirrors> 完整的 settings.xml 文件 <?xml version="1.0" encoding="UTF-8"?> <!-- | This is the configuration file for Maven. It can be specified at two levels: | | 1. User Level. This settings.xml file provides configuration for a single user, | and is normally provided in ${user.home}/.m2/settings.xml. | | NOTE: This location can be overridden with the CLI option: | | -s /path/to/user/settings.xml | | 2. Global Level. This settings.xml file provides configuration for all Maven | users on a machine (assuming they're all using the same Maven | installation). It's normally provided in | ${maven.home}/conf/settings.xml. | | NOTE: This location can be overridden with the CLI option: | | -gs /path/to/global/settings.xml | | |--> <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <!-- Change in below line --> <localRepository>C:\Users\Lenovo\.m2\repository</localRepository> <interactiveMode>true</interactiveMode> <offline>false</offline> <pluginGroups> <!-- pluginGroup | Specifies a further group identifier to use for plugin lookup. <pluginGroup>com.your.plugins</pluginGroup> --> </pluginGroups> <proxies> <!-- <proxy> <id>optional</id> <active>true</active> <protocol>http</protocol> <username>proxyuser</username> <password>proxypass</password> <host>proxy.host.net</host> <port>80</port> <nonProxyHosts>local.net|some.host.com</nonProxyHosts> </proxy> --> </proxies> <servers> <!-- <server> <id>deploymentRepo</id> <username>crunchify</username> <password>crunchify</password> </server> --> </servers> <mirrors> <mirror> <id>alimaven</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> </mirrors> <profiles> </profiles> </settings> 设置 Eclipse Maven Plugin Window -> Preferences -> Maven -> User Settings -> User settings Browse 选择上面创建的 setting.xml -> ok ...

September 14, 2016 · 2 min · 227 words · Me

LeetCode Database Trips and Users 262

262. Trips and Users The Trips table holds all taxi trips. Each trip has a unique Id, while Client_Id and Driver_Id are both foreign keys to the Users_Id at the Users table. Status is an ENUM type of (‘completed’, ‘cancelled_by_driver’, ‘cancelled_by_client’). +----+-----------+-----------+---------+--------------------+----------+ | Id | Client_Id | Driver_Id | City_Id | Status |Request_at| +----+-----------+-----------+---------+--------------------+----------+ | 1 | 1 | 10 | 1 | completed |2013-10-01| | 2 | 2 | 11 | 1 | cancelled_by_driver|2013-10-01| | 3 | 3 | 12 | 6 | completed |2013-10-01| | 4 | 4 | 13 | 6 | cancelled_by_client|2013-10-01| | 5 | 1 | 10 | 1 | completed |2013-10-02| | 6 | 2 | 11 | 6 | completed |2013-10-02| | 7 | 3 | 12 | 6 | completed |2013-10-02| | 8 | 2 | 12 | 12 | completed |2013-10-03| | 9 | 3 | 10 | 12 | completed |2013-10-03| | 10 | 4 | 13 | 12 | cancelled_by_driver|2013-10-03| +----+-----------+-----------+---------+--------------------+----------+ The Users table holds all users. Each user has an unique Users_Id, and Role is an ENUM type of (‘client’, ‘driver’, ‘partner’). ...

September 14, 2016 · 3 min · 436 words · Me

LeetCode Database Department Highest Salary 184

184. Department Highest Salary The Employee table holds all employees. Every employee has an Id, a salary, and there is also a column for the department Id. +----+-------+--------+--------------+ | Id | Name | Salary | DepartmentId | +----+-------+--------+--------------+ | 1 | Joe | 70000 | 1 | | 2 | Henry | 80000 | 2 | | 3 | Sam | 60000 | 2 | | 4 | Max | 90000 | 1 | +----+-------+--------+--------------+ The Department table holds all departments of the company. ...

September 12, 2016 · 2 min · 281 words · Me

LeetCode Database Consecutive Numbers 180

180. Consecutive Numbers Write a SQL query to find all numbers that appear at least three times consecutively. +----+-----+ | Id | Num | +----+-----+ | 1 | 1 | | 2 | 1 | | 3 | 1 | | 4 | 2 | | 5 | 1 | | 6 | 2 | | 7 | 2 | +----+-----+ For example, given the above Logs table, 1 is the only number that appears consecutively for at least three times. ...

September 11, 2016 · 1 min · 173 words · Me

LeetCode Database Second Highest Salary 176

176. Second Highest Salary Write a SQL query to get the second highest salary from the Employee table. +----+--------+ | Id | Salary | +----+--------+ | 1 | 100 | | 2 | 200 | | 3 | 300 | +----+--------+ For example, given the above Employee table, the second highest salary is 200. If there is no second highest salary, then the query should return null. 大体意思 写 SQL 查询出第二高薪水的 Id。如何没有第二高,则返回 null ...

September 11, 2016 · 2 min · 257 words · Me

LeetCode Database Rising Temperature 197

197. Rising Temperature Given a Weather table, write a SQL query to find all dates’ Ids with higher temperature compared to its previous (yesterday’s) dates. +---------+------------+------------------+ | Id(INT) | Date(DATE) | Temperature(INT) | +---------+------------+------------------+ | 1 | 2015-01-01 | 10 | | 2 | 2015-01-02 | 25 | | 3 | 2015-01-03 | 20 | | 4 | 2015-01-04 | 30 | +---------+------------+------------------+ For example, return the following Ids for the above Weather table: ...

September 11, 2016 · 1 min · 127 words · Me

Mybatis Generator 使用配置

MyBatis Generator (MBG) 是一个 Mybatis 的代码生成器。MBG 可以内省数据库的表(或多个表)然后生成可以用来访问(多个)表的基础对象。 这样和数据库表进行交互时不需要创建对象和配置文件。MBG 的解决了对数据库操作有最大影响的一些简单的 CRUD(插入、查询、更新、删除)操作。 Mybatis Generator 文档 Mybatis Generator 官方原版 Mybatis Generator 中文版 通过 Maven 运行 MBG MyBatis Generator (MBG) 包含了一个可以集成到 Maven 构建的 Maven 插件,按照 Maven 的配置惯例,将 MBG 集成到 Maven 很容易。 pom.xml 配置 ... <properties> ... <!-- 设置一些变量 --> <!-- plugin versions --> <plugin.mybatis.generator>1.3.5</plugin.mybatis.generator> <!-- plugin setting --> <mybatis.generator.generatorConfig.xml>${basedir}/src/test/resources/generatorConfig.xml</mybatis.generator.generatorConfig.xml> <mybatis.generator.generatorConfig.properties>file:///${basedir}/src/test/resources/generatorConfig.properties</mybatis.generator.generatorConfig.properties> </properties> ... <build> ... <plugins> ... <!-- Mybatis generator代码生成插件 配置 --> <plugin> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-maven-plugin</artifactId> <version>${plugin.mybatis.generator}</version> <configuration> <configurationFile>${mybatis.generator.generatorConfig.xml}</configurationFile> <overwrite>true</overwrite> <verbose>true</verbose> </configuration> </plugin> </plugins> </build> ... generatorConfig.xml 核心配置 非常完整的 MBG 核心配置文件,配合文档效果更佳。因为有大量的注释篇幅长,建议复制到 xml 文件中查看 generatorConfig.xml 的文件位置要对应在 pom.xml 中的: ...

September 10, 2016 · 4 min · 816 words · Me

SpringMVC 入门使用

本文主要参考了 imooc-SpringMVC 起步 视频教程和 SpringMVC 从入门到精通 系列 - HansonQ ,还有自己的一些总结。 主要内容:MVC 简介、前端控制器模式、SpringMVC 基本概念、SpringMVC 配置、SpringMVC 中的注解、SpringMVC 数据绑定。 MVC 简介 1、MVC 是一种架构模式 程序分层,分工合作,既相互独立,又协同工作,分为三层:模型层、视图层和控制层 2、MVC 是一种思考方式 View:视图层,为用户提供 UI,重点关注数据的呈现,为用户提供界面 Model:模型层,业务数据的信息表示,关注支撑业务的信息构成,通常是多个业务实体的组合 Controller:控制层,调用业务逻辑产生合适的数据(Model),传递数据给视图用于呈现 MVC 设计模式在 B/S 下的应用: ①:浏览器发送请求到控制器(这里要知道控制器的作用) ②:控制器不能处理请求必须交给模型层来处理接着去访问数据库 ③:模型层将处理好的结果返回给控制层 ④:控制层将逻辑视图响应给浏览器(浏览器显示的是渲染过的视图) MVC 本质:MVC 的核心思想是业务数据抽取同业务数据呈现相分离;分离有利于程序简化,方便编程 前端控制器模式 前端控制器模式(Front Controller Pattern)是用来提供一个集中的请求处理机制,所有的请求都将由一个单一的处理程序处理。该处理程序可以做认证/授权/记录日志,或者跟踪请求,然后把请求传给相应的处理程序。 前端控制器(Front Controller)- 处理应用程序所有类型请求的单个处理程序,应用程序可以是基于 web 的应用程序,也可以是基于桌面的应用程序。 调度器(Dispatcher) - 前端控制器可能使用一个调度器对象来调度请求到相应的具体处理程序。 视图(View) - 视图是为请求而创建的对象。 前端控制器的主要作用: 指前端控制器将我们的请求分发给我们的控制器去生成业务数据 将生成的业务数据分发给恰当的视图模版来生成最终的视图界面 SpringMVC 基本概念 对组件说明: DispatherServlet:前端控制器 用户请求到达前端控制器,相当于 MVC 中的 C,而 DispatherServlet 是整个流程的核心,它来调用其他组件来处理用户的请求,前端控制器的存在降低了其他组件之间的耦合度。 HandlerMapping:处理器映射器 它的作用就好比去看电影要拿着电影票根据电影票上面的座位号找到座位其中座位就是 Handler,电影票以及上面的座位号就是 URL HandlerMapping 负责根据用户请求找到 Handler 即处理器,SpringMVC 提供了不同的映射器实现不同的映射方式,例如:配置文件方式,实现接口方式,注解方式等。 Handler:处理器 Handler 是后端控制器,在前端控制器的控制下后端控制器对具体的用户请求进行处理,Handler 涉及到具体的用户业务请求,所以一般情况下需要程序员根据业务需求开发。 HandlerAdapter:处理器适配器 通过 HandlerAdapter 对处理器进行执行,这是适配器模式的应用,通过适配器可以对更多类型的处理器进行执行。播放的电影是 3D 的你看不清楚,因此电影院跟你说你要想看清电影就必须戴 3D 眼镜。也就是说 Handler 满足一定的要求才可以被执行。 ViewResolver:视图解析器 ViewResolver 负责将处理结果生成 View 视图,ViewResolver 首先根据逻辑视图名解析成物理视图名即具体的页面地址,再生成 View 视图对象,最后对 View 进行渲染将处理结果通过页面展示给用户。 ...

September 7, 2016 · 4 min · 826 words · Me

刚刚毕业的两个月小结

走出校园已经两个月了,因为之前的暑期也没怎么在家待过,大一在中康、大二在腾骏、大三在大为,大四毕业也就是现在,所以也没有什么特别的感觉。可以说,这两个月也做了些事情,学了些东西的。 从学校毕业,最直接的影响就是自己更加专注于计算机知识,不用再为学业担心。确定了先走技术的道路,也让自己不那么迷茫做什么。工作规律,自己开始读读书,才觉的读书是件有意思的事。也逼着自己常常写点东西,主要是觉的:写东西的时候自己会主动的思考,文笔练着练着也就能进步吧。 (一) DMV 是毕业后自己第一个项目,全栈开发。初版两周上线,后有花了一周多的时间编写了答题记录的功能。其中的收获是:项目框架的搭建和前端入门知识。原来的项目搭建都不是自己做的,也一直觉的是一件很难的事情。也许就是因为没有做过才觉的难,做过之后也觉的不过如此。项目的页面不多,但都是自己一点点写的,HTML JS 原来也就是自己改改,没有完整写过,这次算是一次不错的锻炼。写前端的时候才发现现在的前端真的是日新月异 AngularJS React 好多好多自己都没有听过的东西,也是从 Mengqi 那里了解到了很多。可惜的是自己没有实际的用上这些,如有机会一定尝试。 DMV 项目流量平平,因为有 Domain 类项目的工作,DMV 的维护就暂时放置了,还是心有不舍的。期间和 John 聊过一次关于产品的事基本总结为: 产品项目是会有失败的,有流量的项目才有维护的意义。 大型项目只有成功与失败之分,没有中间项,失败将代价很大。 不一定要留住用户。 更小的成本更高的流量,高流量后就可以做很多的事。 (二) Domain 信息类项目,使用的架构和 DMV 一致,逻辑更加简单。自己主要做了数据整理,收获是关于 SQL 命令。SQL 就可以直接处理很多的事情。使用了 RMI 做数据同步,用反射写了一段程序,是一次有突破的尝试。 一次看到自己年初的简历,笑了。自己是真敢写,能写个 Hello World 就敢标成了解。从会用到原理,是接下要走的路。 (三) 最近在看设计模式和算法的书,一直在做 LeetCode 的题。设计模式没用过,逮到能用机会绝不错过。算法健脑,刚刚开始接触觉的挺有意思,对数据结构也是种了解。 (四) 再次参加舍友的婚礼,又个结婚了。大一奶了一口,现在成真。祝福 Lu&Feifei。 (五) 来说说程序员那无处安放的创造力 有了锤子想找钉子是很正常的原始冲动,但我们必须认识到,创造力对于程序员这个职业来讲,是锦上添花的东西。如果你没有强大的工程能力,那么创造力也不过是无本之木。所以扎扎实实的把工程基础打好,这是最根本的。 在此基础上,我比较推荐程序员采用内外两条线来培养自己。在公司内的项目上采取相对保守的策略,尽力把稳定性做到最好,培养出自己卓越的工程能力;然后在公司外的开源项目和自己的独立项目上,采用一些新的技术、实践一些新的想法、充分发挥自己的创造力,梦想还是要有的,对吧。 这样做最明显的好处是,你可以了解到新技术和激进方案的优缺点,从而在进行方案选型时,有更多的依据;还有一个职业发展上的好处:如果不是主负责人,公司的项目往往不能代表你的能力;但独立项目却可以作为一个非常好的能力证明出现在你的简历里边。 你可以是一个身怀绝技的手艺人,在自己家里你尝试各种手法各种风格的个人作品;但当你参与颐和园这种级别的工程时,好好的把自己负责的石头雕成总设计师要求的样子就好 —— 毕竟这个时代一个人已经很难负责整个项目了。这就是我所理解的程序员的工匠精神。 摘自:程序员到底是一个什么职业? (尾) 现在自己能听见进去一些原来听不去的话了。我不认为自己是被同化了,也许是心中少了些恶意。 状态不错,继续前进。 – EOF –

August 31, 2016 · 1 min · 59 words · Me

LeetCode Number of 1 Bits 191

191. Number of 1 Bits Write a function that takes an unsigned integer and returns the number of ’1’ bits it has (also known as the Hamming weight). For example, the 32-bit integer ’11’ has binary representation 00000000000000000000000000001011, so the function should return 3. 大体意思 写一个函数,输入一个无符号整数,返回其中值为 1 的比特位的个数(这个值也被称为数字汉明重量) 自己的思路 循环判断最后一位是否是 1 public int hammingWeight(int n) { int result = 0; while (n != 0) { if ((n & 1) == 1) { result++; } n = n >> 1; } return result; } 在 Submit Solution ...

August 31, 2016 · 2 min · 237 words · Me