首页 文章 精选 留言 我的

精选列表

搜索[程序],共10000篇文章
优秀的个人博客,低调大师

Jenkins 构建JAVA的Helloworld程序(学习笔记四)

1、 Jenkins上新建任务,输入任务名,选择构建一个自由风格的软件项目: 2、构建任务上配置:丢弃旧的构建、源码管理选择SVN(SVN的账号密码自己添加)、构建环境选ANT,保存 3、在某一台LINUX服务器上添加两个文件:build.xml helloworld.java #build.xml #helloworld.java packageoata; publicclassHelloWorld{ publicstaticvoidmain(String[]args){ System.out.println("HelloWorld"); } } 4、SVN提交: svn add build.xml svn add helloworld.java svn commit -m "build.xml" build.xml svn commit -m "helloworld.java" helloworld.java 5、执行构建,蓝灯表示构建正常:

优秀的个人博客,低调大师

JSP web应用程序开发教程实验二

版权声明:转载请注明出处:http://blog.csdn.net/dajitui2024 https://blog.csdn.net/dajitui2024/article/details/79396229 编码统一utf-8 文件名:e2alert.html <!DOCTYPE html> <html> <head> <meta http-equiv="Conten-Type" content="text/html; charset=UTF-8"> <title>登录失败</title> </head> <body> <h1 align="center"> 用户名或密码不正确!<br> 没有登录!无权访问本网站! </h1> <h1 align="center"><a href="e2login.html">请登录!</a></h1> </body> </html> 文件名:e2check_login.jsp <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Insert title here</title> </head> <body> <% String name=request.getParameter("username"); String password=request.getParameter("passwd"); if(name.equals("admin") && password.equals("123")) { session.setAttribute("username",name); response.sendRedirect("e2login_success.jsp"); } else { %> <jsp:forward page="e2alert.html"/> <% } %> </body> </html> 文件名:e2login.html <html> <body> <form method=post action="e2check_login.jsp"> <table align="center"> <tr> <td> 用户名: </td> <td> <input type=text name="username"> </td> </tr> <tr> <td> 密码: </td> <td> <input type=text name="passwd"> </td> </tr> <tr> <td colspan=2 align="center"> <input type=submit value="登录"> &nbsp;&nbsp;&nbsp;&nbsp; <input type=reset value="重设"> </td> </tr> </table> </body> </html> 文件名:e2login_success.jsp <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <%@include file="e2session_check.jsp" %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>登录成功</title> </head> <body> <br> <hr width=380> <center> <h1> <% out.print(sename); %> 登录成功 </h1> <h2> 欢迎您!<%=sename %> </h2> </center> </body> </html> 文件名:e2session_check.jsp <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Insert title here</title> </head> <body> <% String sename=(String)session.getAttribute("username"); if(sename==null || !sename.equals("admin")) { response.sendRedirect("e2alert.html"); } %> </body> </html>

优秀的个人博客,低调大师

JSP web应用程序开发教程实验一

版权声明:转载请注明出处:http://blog.csdn.net/dajitui2024 https://blog.csdn.net/dajitui2024/article/details/79396232 编码统一utf-8 文件名:a.jsp <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <html> <head> </head> <body> <% int num = Integer.parseInt(request.getParameter("num")); out.println(num+"的平方是:"+num*num); %> </body> </html> 文件名:b.jsp <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <html> <head> </head> <body> <jsp:include page="a.jsp"> <jsp:param value="19" name="num"/> </jsp:include> </body> </html> 文件名:ex201.jsp <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <html> <head> </head> <body> <% Date date = new Date(); int hour = date.getHours(); int minute = date.getMinutes(); int second = date.getSeconds(); if (hour >= 0 && hour < 12) { out.println("早上好!"); } else if (hour >= 12 && hour < 19) { out.println("下午好!"); } else { out.println("晚上好!"); } %> </body> </html> 文件名:test1.jsp <%@ page contentType="text/html;charset=utf-8" %> <% request.setCharacterEncoding("utf-8"); String strUserName = ""; strUserName = (String)request.getParameter("UserID"); if(strUserName.equals("张三")){ out.println("你好" + strUserName); }else{ out.println("名称错误"); } %> <br>姓名:<%=strUserName%><br> 文件名:test2.jsp <%@ page contentType="text/html;charset=utf-8" %> <html><body> <form action= " test1.jsp" method="post"> <p>姓名:<input type="text" size="20" name= "UserID"></p> <p><input type="submit" value="提 交"> </p> </form> </body></html>

优秀的个人博客,低调大师

编写WordCount程序之一固定格式讲解

WordCount因果图 MapReduce中 map和reduce函数格式 MapReduce中,map和reduce函数遵循如下常规格式: map: (K1, V1) → list(K2, V2) reduce: (K2, list(V2)) → list(K3, V3) Mapper的基类: protected void map(KEY key, VALUE value, Context context) throws IOException, InterruptedException { } Reducer的基类: protected void reduce(KEY key, Iterable<VALUE> values, Context context) throws IOException, InterruptedException { } Context是上下文对象 代码模板 wordcount 代码 代码编写依据,也就是固定写法 input-->map--->reduce->output以下java代码实现此命令的功能bin/hdfs dfs jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.5.0.jar input output package com.lizh.hadoop.mapreduce; import java.io.IOException; import java.util.StringTokenizer; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.IntWritable; import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.io.Text; import org.apache.hadoop.mapreduce.Job; import org.apache.hadoop.mapreduce.Mapper; import org.apache.hadoop.mapreduce.Reducer; import org.apache.hadoop.mapreduce.lib.input.FileInputFormat; import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; public class WordCount { private static Log logger = LogFactory.getLog(WordCount.class); //step1 Mapper class public static class WordCountMapper extends Mapper<LongWritable, Text, Text, IntWritable>{ private Text mapoutputKey = new Text(); private static final IntWritable mapOutputValues = new IntWritable(1);//全局只有一个 @Override protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException { // TODO Auto-generated method stubl String linevalue = value.toString(); StringTokenizer stringTokenizer = new StringTokenizer(linevalue); while(stringTokenizer.hasMoreTokens()){ String workvalue = stringTokenizer.nextToken(); mapoutputKey.set(workvalue); context.write(mapoutputKey, mapOutputValues); logger.info("-----WordCountMapper-----"+mapOutputValues.get()); } } } //step2 Reduce class public static class WordCountReduces extends Reducer<Text, IntWritable, Text, IntWritable>{ private IntWritable reduceOutputValues = new IntWritable(); @Override protected void reduce(Text key, Iterable<IntWritable> vaues,Context context) throws IOException, InterruptedException { int sum =0; for(IntWritable iv:vaues){ sum=sum+iv.get(); } reduceOutputValues.set(sum); context.write(key, reduceOutputValues); } } //step3 driver component job public int run(String[] args) throws Exception{ //1 get configration file core-site.xml hdfs-site.xml Configuration configuration = new Configuration(); //2 create job Job job = Job.getInstance(configuration, this.getClass().getSimpleName()); //3 run jar job.setJarByClass(this.getClass()); //4 set job //input-->map--->reduce-->output //4.1 input Path path = new Path(args[0]); FileInputFormat.addInputPath(job, path); //4.2 map job.setMapperClass(WordCountMapper.class); job.setMapOutputKeyClass(Text.class); job.setMapOutputValueClass(IntWritable.class); //4.3 reduce job.setReducerClass(WordCountReduces.class); job.setOutputKeyClass(Text.class); job.setOutputValueClass(IntWritable.class); //4.4 output Path outputpath = new Path(args[1]); FileOutputFormat.setOutputPath(job, outputpath); //5 submit job boolean rv = job.waitForCompletion(true); return rv ? 0:1; } public static void main(String[] args) throws Exception{ int rv = new WordCount().run(args); System.exit(rv); } } map类业务处理 map 业务处理逻辑 --------------input-------- <0,hadoop yarn> --------------处理--------- hadoop yarn -->split->hadoop,yarn -------------output------- <hadoop,1> <yarn,1> public static class WordCountMapper extends Mapper<LongWritable, Text, Text, IntWritable>{ private Text mapoutputKey = new Text(); //全局只有一个 private static final IntWritable mapOutputValues = new IntWritable(1); @Override protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException { // TODO Auto-generated method stubl String linevalue = value.toString(); StringTokenizer stringTokenizer = new StringTokenizer(linevalue); while(stringTokenizer.hasMoreTokens()){ String workvalue = stringTokenizer.nextToken(); mapoutputKey.set(workvalue); context.write(mapoutputKey, mapOutputValues); logger.info("-----WordCountMapper-----"+mapOutputValues.get()); } } } reduce类业务处理过程 reduce 业务处理过程 map-->shuffle-->mapreduce ------------input(map的输出结果)----------------- <hadoop,1> <hadoop,1> <hadoop,1> ----------------分组---------------- 将相同key的值合并到一起,放到一个集合 <hadoop,1> <hadoop,1> -> <hadoop,list(1,1,1)> <hadoop,1> //step2 Reduce class public static class WordCountReduces extends Reducer<Text, IntWritable, Text, IntWritable>{ private IntWritable reduceOutputValues = new IntWritable(); @Override protected void reduce(Text key, Iterable<IntWritable> vaues,Context context) throws IOException, InterruptedException { int sum =0; for(IntWritable iv:vaues){ sum=sum+iv.get(); } reduceOutputValues.set(sum); context.write(key, reduceOutputValues); } } 优化MapReduce写法 mapReduce 继承configured类, 并实现 Tool接口 tool接口类中的run方法重写 configured 提供初始化工作。 package com.lizh.hadoop.mapreduce; import java.io.IOException; import java.util.StringTokenizer; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configured; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.IntWritable; import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.io.Text; import org.apache.hadoop.mapreduce.Job; import org.apache.hadoop.mapreduce.Mapper; import org.apache.hadoop.mapreduce.Reducer; import org.apache.hadoop.mapreduce.lib.input.FileInputFormat; import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; import org.apache.hadoop.util.Tool; import org.apache.hadoop.util.ToolRunner; public class WordCountMapReduce extends Configured implements Tool { private static Log logger = LogFactory.getLog(WordCountMapReduce.class); //step1 Mapper class public static class WordCountMapper extends Mapper<LongWritable, Text, Text, IntWritable>{ private Text mapoutputKey = new Text(); private static final IntWritable mapOutputValues = new IntWritable(1);//全局只有一个 @Override protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException { // TODO Auto-generated method stubl String linevalue = value.toString(); StringTokenizer stringTokenizer = new StringTokenizer(linevalue); while(stringTokenizer.hasMoreTokens()){ String workvalue = stringTokenizer.nextToken(); mapoutputKey.set(workvalue); context.write(mapoutputKey, mapOutputValues); logger.info("-----WordCountMapper-----"+mapOutputValues.get()); } } } //step2 Reduce class public static class WordCountReduces extends Reducer<Text, IntWritable, Text, IntWritable>{ private IntWritable reduceOutputValues = new IntWritable(); @Override protected void reduce(Text key, Iterable<IntWritable> vaues,Context context) throws IOException, InterruptedException { int sum =0; for(IntWritable iv:vaues){ sum=sum+iv.get(); } reduceOutputValues.set(sum); context.write(key, reduceOutputValues); } } //step3 driver component job public int run(String[] args) throws Exception{ //1 get configration file core-site.xml hdfs-site.xml Configuration configuration = super.getConf();//优化 //2 create job Job job = Job.getInstance(configuration, this.getClass().getSimpleName()); //3 run jar job.setJarByClass(this.getClass()); //4 set job //input-->map--->reduce-->output //4.1 input Path path = new Path(args[0]); FileInputFormat.addInputPath(job, path); //4.2 map job.setMapperClass(WordCountMapper.class); job.setMapOutputKeyClass(Text.class); job.setMapOutputValueClass(IntWritable.class); //4.3 reduce job.setReducerClass(WordCountReduces.class); job.setOutputKeyClass(Text.class); job.setOutputValueClass(IntWritable.class); //4.4 output Path outputpath = new Path(args[1]); FileOutputFormat.setOutputPath(job, outputpath); //5 submit job boolean rv = job.waitForCompletion(true);//true的时候打印日志 return rv ? 0:1; } public static void main(String[] args) throws Exception{ //int rv = new WordCountMapReduce().run(args); Configuration configuration = new Configuration(); //使用工具类运行 int rv = ToolRunner.run(configuration, new WordCountMapReduce(), args); System.exit(rv); } } 抽象出模板 package org.apache.hadoop.mapreduce; import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configured; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.io.Text; import org.apache.hadoop.mapreduce.lib.input.FileInputFormat; import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; import org.apache.hadoop.util.Tool; import org.apache.hadoop.util.ToolRunner; public class WordCountMapReduce extends Configured implements Tool { /** * Mapper Class : public class Mapper<KEYIN, VALUEIN, KEYOUT, VALUEOUT> * * @param args */ public static class WordCountMapper extends // Mapper<LongWritable, Text, Text, LongWritable> { private Text mapOutputKey = new Text(); private LongWritable mapOutputValue = new LongWritable(1); @Override protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException { } } /** * Reducer Class : public class Reducer<KEYIN,VALUEIN,KEYOUT,VALUEOUT> * * @param args */ public static class WordCountReducer extends // Reducer<Text, LongWritable, Text, LongWritable> { private LongWritable outputValue = new LongWritable(); @Override protected void reduce(Text key, Iterable<LongWritable> values, Context context) throws IOException, InterruptedException { // temp sum } } /** * Driver : Create\set\submit Job * * @param args * @throws Exception */ public int run(String[] args) throws Exception { // 1.Get Configuration Configuration conf = super.getConf(); // 2.Create Job Job job = Job.getInstance(conf); job.setJarByClass(getClass()); // 3.Set Job // Input --> map --> reduce --> output // 3.1 Input Path inPath = new Path(args[0]); FileInputFormat.addInputPath(job, inPath); // 3.2 Map class job.setMapperClass(WordCountMapper.class); job.setMapOutputKeyClass(Text.class); job.setMapOutputValueClass(LongWritable.class); // 3.3 Reduce class job.setReducerClass(WordCountReducer.class); job.setOutputKeyClass(Text.class); job.setOutputValueClass(LongWritable.class); // 3.4 Output Path outPath = new Path(args[1]); FileSystem dfs = FileSystem.get(conf); if (dfs.exists(outPath)) { dfs.delete(outPath, true); } FileOutputFormat.setOutputPath(job, outPath); // 4.Submit Job boolean isSuccess = job.waitForCompletion(true); return isSuccess ? 0 : 1; } public static void main(String[] args) throws Exception { Configuration conf = new Configuration(); // run job int status = ToolRunner.run(// conf,// new WordCountMapReduce(),// args); // exit program System.exit(status); } }

优秀的个人博客,低调大师

JavaScript面向对象程序设计(7): 闭包

闭包这个概念看上去很深奥,这个词在离散数学里面的意思确实比较难于理解。在这里,我们先可以把闭包理解成是一种匿名函数或者匿名类。 1. 什么是闭包? 什么是闭包?一种正式的解释是:所谓闭包,指的是一种拥有很多变量并且绑定了这些变量的环境的表达式(通常是一个函数),因而这些变量也是这个表达式的一部分。 相信很多人都不会理解这个定义,因为他的学术味道太浓了——或许你喜欢从字面的语法上进行分析:首先,它是一个表达式,这个表达式绑定了很多变量以及这些变量的环境。不过这并没有什么意义,这依然不会告诉我们什么是闭包。 那么,来看一个例子: functionadd(a) { return function(b) { returna + b; }; } varfunc = add(10); alert(func(20)); 我想经过了前面有关函数的描述,这个例子应该很清楚的理解。JavaScript里面的函数就是对象,他可以做对象能做的一切事情——我们首先定义了一个函数add,它接受一个参数,这个函数返回一个匿名函数,这个匿名函数也接受一个参数,并且会返回这个参数同外部函数的那个参数的和。因此在我们使用的时候,我们将add返回的匿名函数赋值给func,然后调用func,就返回了这两个数的和。 当我们创建一个这样的函数,这个函数内部的一个变量能够在函数外面被引用时,我们就称创建了一个闭包。仔细的品味一下:这就是那个闭包的定义。 看看我们的代码:首先,它有一个内部变量,就是那个匿名函数;其次,这个函数将匿名函数返回了出去,以便外面的变量可以引用到内部定义的变量。 2. 闭包的作用 闭包有什么用呢?或许现在还看不出来,那么看看这段代码: functioninc(a) { vari = 0; return function() { returni; }; } varnum = inc(); alert(num()); 本来,这个变量 i 在函数外面是访问不到的,因为它是 var 定义的,一旦跳出作用域,这个变量就被垃圾回收了,但是,由于我们使用了闭包,在外面是能够访问到这个变量的,因此它并不被垃圾回收! 如果还是不明白闭包的作用,那么看一段应该很熟悉的代码: functionPerson() { varid; this.getId = function() { returnid; } this.setId = function(newId) { id = newId; } } varp = newPerson(); p.setId(1000); alert(p.getId()); // 1000 alert(p.id); // undefined 我们定义一个类Person,它有一个id属性。现在这个属性的行为很像是私有变量——只能通过 setter 和 getter 函数访问到。没错,这就是闭包的一个用途:制造类的私有变量! 闭包还有一个作用:在内存中维护一个变量,不让垃圾回收器回收这个变量。这里的例子就不再举出了。 这里我们只是简单的说了JavaScript的闭包的概念,并没有涉及闭包的内存模型等等之类。这是一个相当重要的概念,Java社区中的部分成员一直对闭包梦寐以求,C#也已经在最新版本中添加了闭包的概念,只不过在那里称为lambda表达式。 本文转自 FinderCheng 51CTO博客,原文链接: http://blog.51cto.com/devbean/174927

资源下载

更多资源
优质分享App

优质分享App

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册
修改密码
忘记密码