首页 文章 精选 留言 我的

精选列表

搜索[桌面应用开发],共10000篇文章
优秀的个人博客,低调大师

使用Spring Boot来加速Java web项目的开发

我想,现在企业级的Java web项目应该或多或少都会使用到Spring框架的。 回首我们以前使用Spring框架的时候,我们需要首先在(如果你使用Maven的话)pom文件中增加对相关的的依赖(使用gradle来构建的话基本也一样)然后新建Spring相关的xml文件,而且往往那些xml文件还不会少。然后继续使用tomcat或者jetty作为容器来运行这个工程。基本上每次创建一个新的项目都是这么一个流程,而我们有时候仅仅想快速的创建一个Spring web工程来测试一些东西,或者是希望能节省时间。 现在我们使用Spring Boot就可以快速的做到这些了。 我们先来看一个非常简单的使用Spring boot的例子吧: 1. 我们创建一个Maven工程,假定工程名字为spring-boot,然后我们在pom.xml文件中加入依赖: 1 2 3 4 5 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version> 1.0 . 2 .RELEASE</version> </dependency> 2. 新建一个Controller来接受处理我们的请求: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; /** * Created by wenchao.ren on 2014/4/26. */ @Controller @EnableAutoConfiguration public class SimpleController { @RequestMapping (value = "/hello" , method = RequestMethod.GET) @ResponseBody public String hello(){ return "hello world" ; } public static void main(String[] args) { SpringApplication.run(SimpleController. class , args); } } 相信大家已经看到了这个Controller有一个main方法,不要急,我们直接运行这个main方法: 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 . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | ' _| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v1. 0.2 .RELEASE) 2014 - 04 - 26 22 : 54 : 40.985 INFO 7236 --- [ main] c.r.spring.boot.SimpleController : Starting SimpleController on rollen with PID 7236 (D:\workspace\GitHub\SpringDemo\spring-boot\target\classes started by wenchao.ren in D:\workspace\GitHub\SpringDemo\spring-boot) 2014 - 04 - 26 22 : 54 : 41.008 INFO 7236 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext @50de0926 : startup date [Sat Apr 26 22 : 54 : 41 CST 2014 ]; root of context hierarchy 2014 - 04 - 26 22 : 54 : 41.583 INFO 7236 --- [ main] .t.TomcatEmbeddedServletContainerFactory : Server initialized with port: 8080 2014 - 04 - 26 22 : 54 : 41.706 INFO 7236 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat 2014 - 04 - 26 22 : 54 : 41.706 INFO 7236 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/ 7.0 . 52 2014 - 04 - 26 22 : 54 : 41.785 INFO 7236 --- [ost-startStop- 1 ] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2014 - 04 - 26 22 : 54 : 41.785 INFO 7236 --- [ost-startStop- 1 ] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 779 ms 2014 - 04 - 26 22 : 54 : 42.055 INFO 7236 --- [ost-startStop- 1 ] o.s.b.c.e.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/] 2014 - 04 - 26 22 : 54 : 42.057 INFO 7236 --- [ost-startStop- 1 ] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [ /*] 2014-04-26 22:54:42.289 INFO 7236 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/ favicon.ico] onto handler of type [ class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 2014 - 04 - 26 22 : 54 : 42.368 INFO 7236 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/hello],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.rollenholt.spring.boot.SimpleController.hello() 2014 - 04 - 26 22 : 54 : 42.376 INFO 7236 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [ class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 2014 - 04 - 26 22 : 54 : 42.377 INFO 7236 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [ class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 2014 - 04 - 26 22 : 54 : 42.447 INFO 7236 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup 2014 - 04 - 26 22 : 54 : 42.459 INFO 7236 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 /http 2014 - 04 - 26 22 : 54 : 42.460 INFO 7236 --- [ main] c.r.spring.boot.SimpleController : Started SimpleController in 1.675 seconds (JVM running for 1.944 ) 2014 - 04 - 26 22 : 54 : 54.963 INFO 7236 --- [nio- 8080 -exec- 1 ] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet' 2014 - 04 - 26 22 : 54 : 54.963 INFO 7236 --- [nio- 8080 -exec- 1 ] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet' : initialization started 2014 - 04 - 26 22 : 54 : 54.971 INFO 7236 --- [nio- 8080 -exec- 1 ] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet' : initialization completed in 8 ms 会产生上面的输出,查看日志可以发现默认使用的是tomcat,端口绑定在8080,现在让我们来访问:http://localhost:8080/hello 就可以看到我们代码中输出的字样:hello world了。 回首这个过程,是不是相比于以前快速了许多呢 参考资料: 1. Spring Boot Reference Guide ============================================================================== 本文转自被遗忘的博客园博客,原文链接:http://www.cnblogs.com/rollenholt/p/3693055.html,如需转载请自行联系原作者

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

iOS开发之在google地图上显示自己的位置

一行代码显示你的位置 iOS中的MapKit集成了定位的功能,使用一行代码就可以在google地图上展示出自己当前的位置,代码如下: -( IBAction ) showLocation:( id ) sender { if ([[btnShowLocation titleForState:UIControlStateNormal] isEqualToString:@ "Show My Location" ]) { [btnShowLocation setTitle:@ "Hide My Location" forState:UIControlStateNormal]; mapView.showsUserLocation = YES ; } else { [btnShowLocation setTitle:@ "Show My Location" forState:UIControlStateNormal]; mapView.showsUserLocation = NO ; } } 关键的代码就是:mapView.showUserLocation=YES. 使用CLLocationManager和MKMapView 还有就是通过CoreLocation框架写代码去请求当前的位置,一样也非常简单: 第一步:创建一个CLLocationManager实例 CLLocationManager *locationManager = [[CLLocationManager alloc] init]; 第二步:设置CLLocationManager实例委托和精度 locationManager.delegate = self ; locationManager.desiredAccuracy = kCLLocationAccuracyBest; 第三步:设置距离筛选器distanceFilter,下面表示设备至少移动1000米,才通知委托更新 locationManager.distanceFilter = 1000.0f; 或者没有筛选器的默认设置: locationManager.distanceFilter = kCLDistanceFilterNone; 第四步:启动请求 [locationManager startUpdatingLocation]; 使用下面代码停止请求: [locationManager stopUpdatingLocation]; CLLocationManagerDelegate委托 这个委托中有:locationManager:didUpdateToLocation:fromLocation方法,用于获取经纬度。 可以使用下面代码从CLLocation 实例中获取经纬度 CLLocationDegrees latitude = theLocation.coordinate.latitude; CLLocationDegrees longitude = theLocation.coordinate.longitude; 使用下面代码获取你的海拔: CLLocationDistance altitude = theLocation.altitude; 使用下面代码获取你的位移: CLLocationDistance distance = [fromLocation distanceFromLocation:toLocation]; 总结:本文主要是讲解了如何在iOS设备google地图上展示自己的当前位置。 本文转自麒麟博客园博客,原文链接:http://www.cnblogs.com/zhuqil/archive/2011/07/13/2105013.html,如需转载请自行联系原作者

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

Android开发实践:自定义带动画的View

对于一个自定义View来说,onMeasure只是用来计算View尺寸,onDraw()才是真正执行View的绘制,所以一般我们都需要重写onDraw()函数来绘制我们期望的UI界面。下面我以一个具体的例子探索自定义View的onDraw()的实现过程和关键点。 我们的目标是制作一个柱状图动画,View的动画启动后,会显示一排柱状图增长的画面,这种动画多用于财务类或者统计类的APP中,效果如图所示(截屏的格式转换过程导致有些变形,还好不影响演示,图中设置了反复播放,真机上只会播放一次): 1. 首先,自定义View的派生类 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 public class AnimatorView extends View{ private PaintmPaint; public AnimatorView(Contextcontext){ super (context); initialize(); } public AnimatorView(Contextcontext,AttributeSetattrs){ super (context,attrs); initialize(); } public AnimatorView(Contextcontext,AttributeSetattrs, int defStyle){ super (context,attrs,defStyle); initialize(); } protected void initialize(){ mPaint= new Paint(); mPaint.setAntiAlias( true ); mPaint.setStyle(Style.FILL); } } 注: Paint是用来绘图的画笔,可以设置其样式、画面的粗细、填充模式、颜色等等。 2. 定义待绘制的图形数据 待绘制的图形数据一般是在程序中动态给出的,这里为了演示,直接定义好: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 public class AnimatorView extends View{ private static final int RECT_WIDTH= 60 ; //每个矩形块的宽度 private static final int RECT_DISTANCE= 40 ; //矩形块之间的间距 private static final int TOTAL_PAINT_TIMES= 100 ; //控制绘制速度,分100次完成绘制 //待绘制的矩形块矩阵,left为高度,right为颜色 private static final int [][]RECT_ARRAY={ { 380 ,Color.GRAY}, { 600 ,Color.YELLOW}, { 200 ,Color.GREEN}, { 450 ,Color.RED}, { 300 ,Color.BLUE} }; private int mPaintTimes= 0 ; //当前已经绘制的次数 } 3. 重载onDraw()函数,实现绘制 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 public class AnimatorView extends View{ @Override protected void onDraw(Canvascanvas){ mPaintTimes++; for ( int i= 0 ;i<RECT_ARRAY.length;i++){ mPaint.setColor(RECT_ARRAY[i][ 1 ]); int paintXPos=i*(RECT_WIDTH+RECT_DISTANCE)+RECT_DISTANCE; int paintYPos=RECT_ARRAY[i][ 0 ]/TOTAL_PAINT_TIMES*mPaintTimes; canvas.drawRect(paintXPos,getHeight(),paintXPos+RECT_WIDTH,getHeight()-paintYPos,mPaint); } if (mPaintTimes<TOTAL_PAINT_TIMES){ invalidate(); //实现动画的关键点 } } } (1) onDraw()函数一般由系统布局管理器来调用,在View第一次加载的时候会调用一次,或者在系统认为需要重绘的时候也会被调用。当然,你也可以在程序中手动触发该View的重绘,通过调用View的invalidate()函数或者postInvalidate()函数即可,前者用于UI线程,后者用于非UI线程。 (2) onDraw()的参数Canvas我们可以理解成系统提供给我们的一块内存区域,所有的绘制都是在这块内存中进行的,绘制完成后系统会显示到屏幕中去。该Canvas对象提供了各种绘制点、线、矩形、圆、位图的方法,基本可以满足各种绘制要求。 (3) drawRect函数需要提供四个坐标,其中,前两个参数代表是被绘制矩形的起始点坐标,后两个参数则是相对于起点的斜对角坐标,注意,原点坐标(0,0)在屏幕的左上角。 (4) 注意,onDraw()每次被调用的时候,原来画布中的内容会被清空。 (5)本示例中,矩形高度每次增加Height/TOTAL_PAINT_TIMES,宽度不变。 4. Activity中测试该View 1 2 3 4 5 6 7 8 9 10 11 12 public class MainActivity extends Activity{ private AnimatorViewmAnimatorView; @Override protected void onCreate(BundlesavedInstanceState){ super .onCreate(savedInstanceState); mAnimatorView= new AnimatorView( this ); setContentView(mAnimatorView); } } 当然,也可以把该View放到layout文件中,这里就不赘述了。 本文转自 Jhuster 51CTO博客,原文链接:http://blog.51cto.com/ticktick/1545863,如需转载请自行联系原作者

资源下载

更多资源
腾讯云软件源

腾讯云软件源

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

Nacos

Nacos

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

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册