mongodb embedded documents query for spring data
2015年12月30日 星期三
2015年6月23日 星期二
Create centos6 USB installer on Mac
原本想使用unetbootin來製做USB安裝程式,但搞老半天,
安裝到一半,就是會出現錯誤訊息
官網有講由 CentOS 6.5 起,你只需透過 dd 把 ISO 檔移至 USB 儲存器,便能利用它進行安裝
所以打開MAC
1.看看掛載的情況 diskutil list
/dev/disk2 就是隨身碟
2.卸載 diskutil unmountDisk /dev/disk2
3.用官網教的指令就能製做出來了
sudo dd if=CentOS-6.5-x86_64-minimal.iso of=/dev/disk2 bs=1m
2015年6月19日 星期五
AWS EC2 Build Tomcat And Single MongoDB
EC2
1.註冊2.進到console home後,選Region
3.Launch Instance
Key Pairs
- 產生[name].pem,並下載,登入時要用
Security groups
- 增加SSH TCP 22 PORT
會自己建立一個VPC
4.產生後,回到Instances 頁面
- 就會新增剛才建立的,可選上方的Connect,可以用 ssh [ubuntu]@[public_ip] -i $PATH/[name].pem 來登入
5.登入後,安裝tomcat, 放程式
sudo apt-get update
sudo apt-get install tomat7
- /usr/share/tomcat7
- /var/log/tomcat7
- /etc/tomcat7
sudo service tomcat7 start
sudo apt-get install default-jdk
sudo apt-get install maven
git clone https://xxx@code.google.com/p/projectname/
git pull
./sudo mvn clean
./sudo mvn install
sudo vim /etc/tomcat7/server.xml
Mongodb
1.可由Launch Instance選擇AMI 或 Service -> CloudFormation 使用template來建立先簡單化,這裡使用template, 並安裝在原來的VPC上,
且Replica Set只建一個
安裝過程中
Subnet-xxxxxx 要輸入 Network Interface 頁面裡 同一個VPC所對應的Subnet ID
會產一個新的instance
同樣方式連進去
ssh [ubuntu]@[public_ip] -i $PATH/name.pem
登入後,執行command
mongo
config = { _id: "r0", members: [ { _id:0, host:"127.0.0.1:27017" }] }
use testdb
db.createUser("root","password")
Send Email
選Service -> SES -> SMTP Settings1.Server Name
2.Create My SMTP Credentials 要認證過的email,才收的到信
3.上線前,需於Support Center寫信給官方,才能離開sandbox
Ref
April 2015
2014年10月26日 星期日
org.springframework.web.context.ContextLoaderListener
使用 Spring 3.2.x 時, 只要一讀取
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
就會出現下面Exception
原來是因為我Tomcat使用了JDK1.8
若要用1.8, Spring必須upgrade成4才會支援1.8的byte code format
--
ERROR [org.springframework.web.context.ContextLoader] - <Context initialization failed>
java.lang.IllegalArgumentException
at org.springframework.asm.ClassReader.<init>(Unknown Source)
at org.springframework.asm.ClassReader.<init>(Unknown Source)
at org.springframework.asm.ClassReader.<init>(Unknown Source)
嚴重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.IllegalArgumentException
at org.springframework.asm.ClassReader.<init>(Unknown Source)
at org.springframework.asm.ClassReader.<init>(Unknown Source)
at org.springframework.asm.ClassReader.<init>(Unknown Source)
2014-10-26 22:00:13,255 WARN [org.springframework.web.context.support.XmlWebApplicationContext] - <Exception thrown from ApplicationListener handling ContextClosedEvent>
java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: Root WebApplicationContext: startup date
at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:347)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:334)
[org.springframework.web.context.support.XmlWebApplicationContext] - <Exception thrown from LifecycleProcessor on context close>
java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: Root WebApplicationContext: startup date
at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:360)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1057)
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1010)
2014年9月10日 星期三
Design Pattern - CQRS
CQRS
ref:
http://johnnycoder.com/blog/2009/12/18/learn-domain-driven-design/
http://www.codeproject.com/Articles/555855/Introduction-to-CQRS
通常進行CRUD會有二個問題
collaboration 同時操作相同資料時
staleness 某筆資料, 當A查詢後, B修改
collaboration 同時操作相同資料時
staleness 某筆資料, 當A查詢後, B修改
Command
Query
image source : http://www.udidahan.com/2009/12/09/clarified-cqrs/
image source : http://www.codeproject.com/Articles/555855/Introduction-to-CQRS
image source : http://msdn.microsoft.com/en-us/library/jj591573.aspx
2014年9月5日 星期五
Facebook 自訂分享按鈕
1.在html tag內加入 xmlns:og、xmlns:fb屬性
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:og="http://ogp.me/ns#"
xmlns:fb="http://www.facebook.com/2008/fbml">
2.head tag加入
<meta name="og:description" content="" />
<meta property="og:title" content=""/>
<meta property="og:type" content="website"/>
<meta property="og:url" content=""/>
<meta property="og:image" content=""/> 縮圖, 可設定多圖
<meta property="og:site_name" content="" />
<meta property="fb:app_id" content="" />
<meta property="fb:admins" content=""/>
3.body tag裡面加入
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({appId: 'app id', status: true, cookie: true, xfbml: true});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol + '//connect.facebook.net/zh_TW/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
4.清除facebook cache
https://developers.facebook.com/tools/debug
5.在要點擊分享的按鈕加上
<a href="https://www.facebook.com/sharer/sharer.php?u=url" target="_blank">分享到FACEBOOK</a>
或
<a target="_blank" onclick="return !window.open(this.href, 'Facebook', 'width=640,height=300')" href="http://www.facebook.com/sharer/sharer.php?u=url">分享到FACEBOOK</a>
補充
1.自動產生連結網站 http://www.sharelinkgenerator.com/

