dubbo springmvc 整合

dubbo 介绍

http://dubbo.io/
https://github.com/dangdangdotcom/dubbox

阅读更多

springmvc spring mybatis druid 整合

新建项目


阅读更多

hibernate maven is not mapped 错误

使用idea maven 建立ssh 项目,所有的文件配置好以后,出现

1
2
3
4
5
6
7
8
9
Struts Problem Report

Struts has detected an unhandled exception:

Messages:
GroupEntity is not mapped
GroupEntity is not mapped [from GroupEntity ]
File: org/hibernate/hql/internal/ast/util/SessionFactoryHelper.java
Line number: 189

阅读更多

NSNotificationCenter 通知

注册通知

1
[[NSNotificationCenter defaultCenter] postNotificationName:@"musicNotify" object:[help convertFromMusicEntity:music]];

阅读更多

NSUserDefaults 保存模型

1
2
3
let userNsData = NSUserDefaults() // 定义
let userNsData = NSKeyedArchiver.archivedDataWithRootObject(userModel) //打包
userNsData.setObject(userNsData, forKey: "userData") //存储

阅读更多

uialertcontroller

http://nshipster.cn/uialertcontroller/

阅读更多

IOS 导航栏透明

1
2
3
4
5
6
7
8
9
10

private func applyTransparentBackgroundToTheNavigationBar(opacity:CGFloat) -> Void {
UIGraphicsBeginImageContextWithOptions(CGSize(width: 1,height: 1), false, (self.navigationController?.navigationBar.layer.contentsScale)!)
let context = UIGraphicsGetCurrentContext()
CGContextSetRGBFillColor(context, Constant.NAVI_BAR_COLOR_RED, Constant.NAVI_BAR_COLOR_GREEN, Constant.NAVI_BAR_COLOR_BLUE, opacity)
UIRectFill(CGRectMake(0, 0, 1, 1))
let transParentBackground = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
navigationController?.navigationBar.setBackgroundImage(transParentBackground, forBarMetrics: UIBarMetrics.Default)
}

阅读更多

SQLite.swift 简单使用

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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
//
// CarHelper.swift
// internet_car_swift
//
// Created by 郭晓天 on 16/6/11.
// Copyright © 2016年 lzq. All rights reserved.
//

import UIKit
import SQLite

class CarHelper: NSObject {

let cars = Table("cars")

private var db: Connection!

let id = Expression<Int64>("id")
let qcpp = Expression<String?>("qcpp")
let qcxh = Expression<String>("qcxh")
let qylx = Expression<String>("qylx")
let qcfdj = Expression<String>("qcfdj")
let qccp = Expression<String>("qccp")

override init() {
super.init()
initDb()
}

/**
初始化数据库,建表

- returns: Void
*/
func initDb(){

let path = NSSearchPathForDirectoriesInDomains(
.DocumentDirectory, .UserDomainMask, true
).first!

do{
db = try! Connection("\(path)/db.sqlite3",readonly: false)

try db.run(cars.create(ifNotExists: true) { t in // CREATE TABLE "users" (
t.column(id, primaryKey: true) // "id" INTEGER PRIMARY KEY NOT NULL,
t.column(qcpp) //
t.column(qcxh)
t.column(qylx)
t.column(qcfdj)
t.column(qccp)
})

}catch let error as NSError{
print(error)
print("创建数据库失败")
}
}

/**
存入数据

- parameter car: 模型

- returns: 是否成功
*/
func saveData(car:CarDetail) -> Bool {
let insert = cars.insert(
qcpp <- car.qcpp!,
qcxh <- car.qcxh!,
qylx <- car.qylx!,
qcfdj <- car.qcfdj!,
qccp <- car.qccp!
)
do{
try db.run(insert)
return true
}catch let error as NSError{
print(error)
return false
}
}

/**
获取数据

- returns: 数组
*/
func getData() -> [CarDetail] {
var allCar = [CarDetail]()
for car in try! db.prepare(cars) {
let carm = CarDetail()
carm.id = Int(car[id])
carm.qcpp = car[qcpp]
carm.qcxh = car[qcxh]
carm.qylx = car[qylx]
carm.qcfdj = car[qcfdj]
carm.qccp = car[qccp]
allCar.append(carm)
}
return allCar
}

/**
删除数据

- parameter carid: 数据id

- returns: 是否成功
*/
func deleteById(carid:Int) -> Bool {
let ii = Int64(carid)
let alice = cars.filter(id == ii)

do {
if try db.run(alice.delete()) > 0 {
return true
} else {
return false
}
} catch {
return false
}
}

}

阅读更多

iOS本地通知

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

#define kLocalNotificationKey @"kLocalNotificationKey"
#import "LocationNotivfcation.h"

@implementation LocationNotivfcation

+ (void) addLocationNotification{
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
//触发通知时间
localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:10];
//重复间隔
// localNotification.repeatInterval = kCFCalendarUnitMinute;
localNotification.timeZone = [NSTimeZone defaultTimeZone];

//通知内容
localNotification.alertBody = @"发动机异常请检查";
localNotification.applicationIconBadgeNumber = 1;
localNotification.soundName = UILocalNotificationDefaultSoundName;

//通知参数
localNotification.userInfo = @{kLocalNotificationKey: @"fdj"};

localNotification.category = kNotificationCategoryIdentifile;

[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
}
+ (void) cancelLocationNotivication{
for (UILocalNotification *obj in [UIApplication sharedApplication].scheduledLocalNotifications) {
if ([obj.userInfo.allKeys containsObject:kLocalNotificationKey]) {
[[UIApplication sharedApplication] cancelLocalNotification:obj];
}
}
//直接取消全部本地通知
//[[UIApplication sharedApplication] cancelAllLocalNotifications];
}

+(void)setupLicationNotification{
UIUserNotificationSettings *uns = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound) categories:nil];
// [[UIApplication sharedApplication] registerForRemoteNotifications];
[[UIApplication sharedApplication] registerUserNotificationSettings:uns];

}
@end

阅读更多

Raspberry pi 搭建 dns server

最近dns真是。。。github都上不去。。。还是自建一个吧。
树莓派搭建dns服务器
我使用的是树莓派1 在性能方面可能不是很强,但是能用。

阅读更多