2018년 2월 19일 월요일

Microsoft Visual Studio - Package Installation Error

Error Message


---------------------------
Microsoft Visual Studio
---------------------------
Package Installation Error
Could not add all required packages to the project. The following packages failed to install from 'C:\Program Files (x86)\Microsoft Web Tools\Packages':

jQuery.1.10.2 : Failed to initialize the PowerShell host. If your PowerShell execution policy setting is set to AllSigned, open the Package Manager Console to initialize the host first.
Microsoft.Web.Infrastructure.1.0.0.0 : Failed to initialize the PowerShell host. If your PowerShell execution policy setting is set to AllSigned, open the Package Manager Console to initialize the host first.
Modernizr.2.6.2 : Failed to initialize the PowerShell host. If your PowerShell execution policy setting is set to AllSigned, open the Package Manager Console to initialize the host first.
---------------------------

---------------------------
Microsoft Visual Studio
---------------------------
Failed to initialize the PowerShell host. If your PowerShell execution policy setting is set to AllSigned, open the Package Manager Console to initialize the host first.
---------------------------


Solution

The command in PowerShell (as administrator) 
-----------------------------
start-job { Set-ExecutionPolicy Unrestricted } -RunAs32 | wait-job | Receive-Job
-----------------------------
Enter

Restart Visual Studio

2017년 2월 22일 수요일

[expressjs] express-ejs-layouts 적용하기

asp.net mvc를 사용하다가 node express를 사용해보려고 생각했다.

예제 사이트를 따라서 실행하고 다른 페이지도 추가하려고 보니 asp.net mvc의 master page와 같은 구조가 아니라 (공통 레이아웃) 페이지마다 작업을 해야하는 구조였다.
샘플 코드일테니 당연하겠지만...

찾아보니 express-ejs-layouts 을 이용해서 처리할 수가 있었다.

1. 설치부터 npm install express-ejs-layouts --save
2. app.js 파일을 아래와 같이 수정 합니다.


3. 확인을 위해 실행 npm start
하지만 생각과는 다르게 오류가 발생 합니다. views 폴더에서 layout view를 찾을 수 없다는 군요.

4. add file - layout.ejs 파일을 추가하고 합니다.
<%- body %> 이 영역에 다른 ejs 파일의 내용이 삽입됩니다.

5. index.ejs 파일을 열어서 내용을 수정 합니다.

6. 다시 실행 합니다. npm start

2015년 7월 22일 수요일

[mybatis-spring] batch insert

mybatis - spring with batch insert.

mybatis 사이트를 참고해서 batch insert 작업을 하였습니다.
그러나, 참고 사이트에서는 상세한 정보를 얻을 수 없어서 고생을 하였지요.
담에 할 때는 쉽게 되겠지요? ^^


-- [Reference Site]
mybatis introduction
mybatis-spring introduction

-- [spring config]
<bean id="normalSqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="configLocation" value="classpath:ibatis/sqlMapConfig.xml" />
<property name="dataSource" ref="dataSource" />
</bean>

<bean id="batchSqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="configLocation" value="classpath:ibatis/sqlMapConfig.xml" />
<property name="dataSource" ref="dataSource" />
</bean>

<bean id="normalSqlSessionTemplate" name="normalSqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg ref="normalSqlSessionFactory" />
</bean>

<bean id="batchSqlSessionTemplate" name="batchSqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg index="0" ref="batchSqlSessionFactory" />
<constructor-arg index="1" value="BATCH" />
</bean>


-- [ServiceImpl]
@Service
public class BatchServiceImpl implements BatchService {
@Autowired
BatchDao batchDao;

public int batchInsert (List<MyDomain> params) {
//List<MyDomain> myDomains = new ArrayList<MyDomain>();
List<MyDomain> myDomains = params;

for (int i = 0; i < 100; i++) {
MyDomain myDomain = new MyDomain();
myDomain.setProperty1(String.valueOf(i));
myDomain.setProperty1("Name");

myDomains.add(myDomain);
}
return batchDao.InsertCodes(myDomains);
}
}


-- [DAO]
public class BaseDao {
@Autowired
@Qualifier("normalSqlSessionTemplate") -- 일반 DAO 처리
SqlSessionTemplate normalSqlSessionTemplate;

@Autowired
@Qualifier("batchSqlSessionTemplate") -- 배치 DAO 처리
SqlSessionTemplate batchSqlSessionTemplate;

public SqlSession getSqlSession() {
return signSqlSessionTemplate;
}

public SqlSession getSqlBatchSession() {
return batchSqlSessionTemplate;
}
}
@Repository
public class BatchDao extends BaseDao {
public void InsertCodes (List<MyDomain> myDomains) {
for (MyDomain myDomain : myDomains) {
getSqlBatchSession().insert("insert_Batch", myDomain);
}
}
}


-- [Mapper]
<insert id="insert_Batch" parameterType="packagename.MyDomain">
<selectKey resultType="int" keyProperty="myKey" order="AFTER" >
select 1 from dual;
</selectKey>
INSERT /* insert_Batch */
INTO table_name
(
property_1
, property_2
)
VALUES
(
#{property_1}
, #{property_2}
)
</insert>
-- warning: If you do not have SekectKey Tag, an protocol violation error occurs.