노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


Eclipse, 색상 테마 (color theme) 변경



-foreground, background, class, method, string, operator, keyword등등


1. Eclipse Marketplace를 통해, Color Theme 설치하기


설치후 변경 메뉴 :



2. 추가 테마 다운로드

http://www.eclipsecolorthemes.org/



1) Import XML


2) Import EPF(Eclipse Preference) , without install plugin 


추천 1

Monokai Soda Sublime Text  : http://www.eclipsecolorthemes.org/?view=theme&id=6862


추천 2

Sublime Scala : http://www.eclipsecolorthemes.org/?view=theme&id=11461



원문 :

https://www.mkyong.com/eclipse/how-to-change-eclipse-theme/


제거하기

Navigate to Windows>Preferences>Java>Editor.
Click on Syntax Coloring.
Click "Restore Defaults" and "Apply".

Then, navigate to General>Editors.
Click on Text Editors.
Click on "Restore Defaults" and "Apply".



'Web Tech. > Spring Framework' 카테고리의 다른 글

Tomcat JDBC Connection Pool  (0) 2016.12.20
SVN 연결 해제, 재연결  (0) 2016.12.15
Ramda 표현식  (0) 2016.11.15
Java IO Package  (0) 2016.11.15
java.util Collection Framework  (0) 2016.11.14
블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


Ramda 표현식


-- Java 8부터 지원



사용 예제

package ramda;

public class RamdaExam {

	public static void main(String[] args) {

		// Method를 하나만 갖는 interface를 함수형 Interface라고 하고,
		// Runnable interface, run method만 존재
/*
				
		// Method는 객체 를 통해서만 전달 가능한데,
		 
		new Thread( new Runnable() {

			@Override
			public void run() {
				
				for(int i=0; i< 10;  i++ ) {
					System.out.println("hello " + i);
				}
			}
		}).start();
*/
		
		// Method만 전달 할 수 있다면...
		// 그래서,
		// ramda 표현식 , 일명 익명 Method
		new Thread( () -> {

			for(int i=0; i< 10;  i++ ) {
				System.out.println("hello " + i);
			}

		}).start();

		// ramda 표현식
		// (매개변수 목록) -> { 실행문 }
	}
}



출처 :

http://tryhelloworld.co.kr/courses/자바-중급/lessons/람다식-기본문법

블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.




Java IO Package



- Byte 단위 입출력

- Char 단위 입출력


- 4가지 abstract(추상) Class : InputStream , OutputStream, Reader, Writer


장식대상 클래스

- 입력 대상 Class : File~ or ByteArray~



장식하는 클래스

- DataInputStream/DataOutputStream : 다양한 형을 입력받고 출력 

- BufferedReader : readLine() 메소드 보유

- PrintWriter : println() 메소드 보유



Java IO는 Decorator Pattern을 사용한다.

    : 생성자에서 감싸서 새로운 기능을 추가




출처 :


http://tryhelloworld.co.kr/courses/자바-중급/lessons/자바io

블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


java.util Collection Framework



java.util패키지에는 자료를 다룰 수 있는 자료구조 클래스가 다수 존재하고, 자료구조 클래스들을 Collection Framework이라고 한다.



java 2에서 등장




Collection interface, 가장 기본이 되는 Interface

- 중복 허용

- 저장된 순서를 모름

- 저장된 자료를 하나씩 꺼낼 수 있는 iterator라는 인터페이스 반환


Set 자료 구조

- 중복을 허용하지 않는 자료 구조, add시 있으면 false 리턴


List 자료 구조

- 중복을 허용하면서 순서를 기억하는 자료 구조

- 순서를 기억하기 떄문에, get(int)에서 몇번째 인지를 int값에 전달



Map 자료 구조

- 저장할떄, put()메소드를 이용하여 key와 value를 함께 저장

- key가 중복 될 수는 없음

- 동일 key로 추가할떄는 새로운값으로 저장됨

- 원하는 값을 꺼낼때는 key를 매개변수로 받아들이는 get()메소드를 이용하여 값을 꺼낸다.

- key 전체 리스트는 keySet()을 통해 얻은 Set의 iterator()를 사용한다.




출처 : try helloworld 동영상 강좌 ( 꼭~ 보세요 )


http://tryhelloworld.co.kr/courses/자바-중급/lessons/컬렉션-프레임워크,자바중급(파트8)


파트 1.) Object 클래스        2강


- Object 클래스는 모든 클래스의 최상위 클래스

- 아무것도 상속받지 않아도 자동 상속, 모든 클래스에서 Object 메소드를 사용 가능

- equals, toString, hashCode


파트 2. java.lang 패키지    8강


- JAVA는 기본적으로 다양한 package를 지원, 그 중에서 가장 중요한 패키지

- java.lang패키지의 클래스는 import하지 않고도 사용할 수 있다.

- 기본형 타입을 객체로 변환시킬때 사용하는 Wrapper클래스

- 모든 클래스의 최상위 클래스인 Object 클래스

- 문자열과 관련된 String, StringBuffer, StringBuilder

- 화면에 값을 출력할때 사용하는 System 클래스

- 수학과 관련된 Math 클래스

- Thread에 관련된 중요 클래스ㅡ


파트 3. java.util 패키지    9강


- 유용한 클래스들을 많이 가지고 있는 패키지

- 날짜와 관련된 Date, Calendar클래스

- Date클래스가 지역화를 지원하지 않는 문제를 해결하기 위한 Calendar클래스

- 지역화와 관련된 Locale로 시작되는 이름을 가진 클래스

- List, Set, Collection, Map의 자료구조, 컬렉션 프레임워크와 관련된 Interface


파트 4. 날짜와 시간 (java.util package)       5강


- 날짜와 시간을 구하는 Date클래스, Calendar, java.time 패키지

파트 5. (자바)IO             11강


- 입출력을 위한 인터페이스와 클래스

- 자바 IO는 크게 byte단위 입출력과 문자 단위 입출력 클래스를 구분

-- byte단위 입출력 클래스는 InputStream과 OutputStream이라는 추상클래스를 상속

-- 문자(char)단위 입출력 클래스는 모두 Reader와 Writer라는 추상 클래스를 상속

- 파일 입력/출력

: FileInputStream, FileOutputStream, FileReader, FileWriter

- 배열로 부터 입력/출력

: ByteArrayInputStream, ByteArrayOutputStream, CharReader, CharWriter

- DataInputStream, DataOuputStream은 다양한 데이터형을 입/출력

- PrintWriter는 다양하게 한줄 출력하는 println()메소드 제공

- BufferedReader는 한줄 입력하는 readLine() 메소드 제공


파트 6. 어노테이션        2강


- 어노테이션은 Java5에 추가된 기능

- 어노테이션은 클래스나 메소드위에 붙고, @기호로 이름이 시작

- 어노테이션은 소스코드에 메타코드를 붙인후, 클래스가 컴파일 되거나 실행될때 어노테이션에 설정된 값을 통하여 클래스가 좀 더 다르게 실행되게 할 수 있다. 이런 이유로 어노테이션을 일종의 설정파일처럼 설명하는 경우가 있다

- 어노테이션은 사용자가 직접 만들 수도 있다 - Custom 어노테이션


파트 7. 쓰레드              11강


- 쓰레드란 동시에 여러가지 작업을 동시에 수행할 수 있게 하는것

- JAVA 프로그램은 운영체제에서 하나의 프로세스(실행되는 프로그램)로 실행하는 JVM위에서 동작

- 자바에서 Thread를 만드는 방법 : Thread클래스를 상속 or Runnable인터페이스를 구현


파트 8.  람다                 3강


- 람다식은 다른말로 익명 메소드라고 한다.
- 인터페이스 중에서 메소드를 하나만 가지고 있는 인터페이스를 함수형 인터페이스라고 한다.  : Runnable인터페이스는 run()메소드 하나만 제공


'Web Tech. > Spring Framework' 카테고리의 다른 글

Ramda 표현식  (0) 2016.11.15
Java IO Package  (0) 2016.11.15
에러 : java.lang.IllegalArgumentException: Document base  (2) 2016.11.11
AES 암호화(encryption)  (0) 2016.10.27
메모리 누수, Memory Leak  (0) 2016.09.27
블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


에러 메시지 :


java.lang.IllegalArgumentException: Document base



does not exist or is not a readable directory
    at org.apache.naming.resources.FileDirContext.setDocBase(FileDirContext.java:142)
    at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4324)





일반적인 조치 방법 :


- eclipse(이클립스)에서 등록된 프로젝트를 reload를 하면, 대체로 해결이 된다.





여전히 에러가 나는 경우에 추가로 확인할 부분들은... :


- eclipse(이클립스)에서 빌드 에러가 있는지를 살펴 봐라.




- 혹시 eclipse(이클립스) 프로젝트의 속성에서 Web Deployment Assembly가 보이는지 확인을 해 본다.





- 위의 항목이 보이지 않는다면, eclipse(이클립스)에서 빌드를 하지 못하니, 

.project 파일에 아래 항목을 추가하라.


<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>

'Web Tech. > Spring Framework' 카테고리의 다른 글

Java IO Package  (0) 2016.11.15
java.util Collection Framework  (0) 2016.11.14
AES 암호화(encryption)  (0) 2016.10.27
메모리 누수, Memory Leak  (0) 2016.09.27
Spring Boot 소개 (3) - JPA , MySQL  (1) 2016.09.22
블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


AES , 암호화(encryption) / 복호화(decryption)




말레이시아 Payment Gateway업체 연동중에 구현...



-- Wiki ( 나무위키, Wikipedia )


Advance Encryption Standard, 벨기에의 2명의 암호학자가 만든 알고리즘이며,

NIST(National Institute for Standard and Testing)가 제정하고, 미국 정부가 채택한 후 확산.



대칭 암호화 표준규격으로, HW와 SW 양쪽에 효율적이도록 디자인 되었다

지원하는 Block 길이는 128 bits, 192bits, 256 bits이다




PHP, Java 예제 소스



아래 암호화 결과는 문자의 코드화로 생기는 문제로 인해서 base64로 부호화된다.



http://aesencryption.net/ (128 bits )



http://boxfoxs.tistory.com/270 (128 bits)





Java에서 Base64 codec으로 commons.apache.org의 Components->Codec받기


위치 : http://commons.apache.org/proper/commons-codec/


최신 버젼 : http://commons.apache.org/proper/commons-codec/download_codec.cgi





JavaScript 예제 소스



http://ironnip.tistory.com/80 (128 bits)




256 bits


import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.SecretKeySpec;

import org.apache.commons.codec.binary.Base64;

/**
 *  
 * 
 * 
 * HashValue.java
 * 
* @author admin * @date 2016. 10. 26. * @Version : 0.1 */ public class HashValue { private SecretKeySpec secretKey = null; private String encryptString = ""; public void setKey(String myKey) throws UnsupportedEncodingException, NoSuchAlgorithmException { byte[] key1 = null; byte[] keyDigest; MessageDigest sha = null; // Set Key key1 = myKey.getBytes("UTF-8"); System.out.println("setKey.key1.length = " + key1.length ); // SHA-256 sha = MessageDigest.getInstance("SHA-256"); keyDigest = sha.digest(key1); setSecretKey ( new SecretKeySpec(keyDigest,"AES") ); } public String encryption( String unhashedValue ) { Cipher cipher = null; try { cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); if ( secretKey == null ) { System.out.println("encryption.SecretKey is not ready."); return ""; } cipher.init(Cipher.ENCRYPT_MODE, getSecretKey()); setEncryptString ( Base64.encodeBase64String ( cipher.doFinal( unhashedValue.getBytes("UTF-8") )) ); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (NoSuchPaddingException e) { e.printStackTrace(); } catch (InvalidKeyException e) { e.printStackTrace(); } catch (IllegalBlockSizeException e) { e.printStackTrace(); } catch (BadPaddingException e) { e.printStackTrace(); } return encryptString; } public String getEncryptString() { return encryptString; } private void setEncryptString(String encryptString) { this.encryptString = encryptString; } private SecretKeySpec getSecretKey() { return secretKey; } private void setSecretKey(SecretKeySpec secretKey) { this.secretKey = secretKey; } }

* AES에서는 기본값으로 128 bits 키를 지원하며, 만약에 192 bits 또는 256 bits의 key를 사용하게 되면, java 컴파일러는 illegal key size, invalid key exception을 일으킨다.


java.security.InvalidKeyException: Illegal key size or default parameters
 at javax.crypto.Cipher.checkCryptoPerm(Cipher.java:1026)
 at javax.crypto.Cipher.implInit(Cipher.java:801)
 at javax.crypto.Cipher.chooseProvider(Cipher.java:864)
 at javax.crypto.Cipher.init(Cipher.java:1249)
 at javax.crypto.Cipher.init(Cipher.java:1186)


해결 방법은 JCE( Java Cryptography Extension)을 JRE version(Java 6,7,8)에 맞게 다운로드 해야 하고,

1) local_policy.jar와 2) US_export_policy.jar를

/jre/lib/security위치의 파일과 교체해야 한다.


-- 관련 이슈 논의글

http://stackoverflow.com/questions/6481627/java-security-illegal-key-size-or-default-parameters



--  jce-7-download


--  jce-8-download

블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


하나의 메모리 누수를 잡기까지

실행중인 프로세스를 연결하기


jmap

> jmap -histo:live <pid> | more

num    # instances    #bytes    class name  
----------------------------------------------
1:    3062256    677810312    [C  
2:    3176949    76246776        java.lang.String  
3:    29959    32072704        [I  
4:    380080    27365760        xxx.xxx.common.model.xxxx

위의 연결 방법이 거부 당할때

> jmap -F -dump:live, format=b, file=heap.bin <pid>


참조 : http://d2.naver.com/helloworld/1326256



힙 덤프 분석

Eclipse/이클립스 Memory Analyzer ,

다운로드 : Eclipse Marketplace 


덤프 파일 분석 분석


덤프 파일을 읽어서 ( File -> Open Heap Dump ) 분석을 진행...

Dominator Tree, Top Consumers등의 정보를 확인하여, 가장 큰 원인을 찾아 본다.


참조 : http://www.vogella.com/tutorials/EclipseMemoryAnalyzer/article.html



Java Memory Analysis

메모리 분석 힙(Heap)


jhat

> jhat -J-mx2048m heap.bin   [http://localhost:7000/]


참조 : http://kwonnam.pe.kr/wiki/java/memory



블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


Spring Boot 소개 , JPA / MySQL , Maven



프로젝트 생성하기 ( start.spring.io )

Maven Project에서 Packaging은 War로 변경하고, Web/JPA/MySQL Dependency를 선택한다. Generate Project 버튼을 누르고, Zip파일을 다운로드 한다.


다운로드 Zip 파일은 원하는 프로젝트 폴더에 Unzip를 한다.


프로젝트 Import하기

Project from Folder or Archive를 선택하고, Next를 누른다.


*Perspective는 Spring환경으로 설정을 해야 한다.



아래와 같은 pom.xml를 확인할 수 있다.


application.properties에 MySQL 관련 정보를 추가 한다.

* url의 database는 생성이 되어 있어야 한다. ( table은 자동 생성됨 )

#
# mysql connection
#
spring.datasource.url=jdbc:mysql://localhost:3306/test_spring_boot
spring.datasource.username=root
spring.datasource.password=root
spring.jpa.hibernate.ddl-auto=update

-hibernate.ddl-auto는 상용서비스(실제 서비스용)에서는 사용하지 않는게 맞다.

validate : validate the schema, makes no changes to the database.

update : update the schema

create : creates the schema, destroying previous data ( app재시작시에 모두 재생성됨)

create-drop : drop the schema at the end of the session

Class/Interface 작성 ( control, model, dao - Package )

@Entity, @Id, @GeneratedValue, @Column를 사용

@Controller, @Autowired, @RequestMapping, @ResponseBody를 사용




실행 결과


1) 전체 리스트 조회


2) 추가하기

3) 다시, 전체 리스트 조회

4) 자동 생성된 Table




관련 이슈 논의 stackoverflow

http://stackoverflow.com/questions/27981789/how-to-use-spring-boot-with-mysql-database-and-jpa

블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


Spring Boot Actuator


Actuator는 매우 도움을 주는 라이브러리로 어플리케이션의 자세한 런타임정보를 제공한다.


pom.xml ( Maven )에 추가 하기


<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-actuator</artifactId>
    <version>1.3.3.RELEASE</version>
</dependency> 


Application Health 호출 ( http://localhost:8080/health )



그외 정보들


URL
Desc
env Exposes properties from Spring’s ConfigurableEnvironment.
beans Displays a complete list of all the Spring beans in your application.
configprops Displays a collated list of all @ConfigurationProperties.
dump Performs a thread dump.
health Shows application health information (when the application is secure, a simple ‘status’ when accessed over an unauthenticated connection or full message details when authenticated).
logfile Returns the contents of the logfile (if logging.file or logging.path properties have been set). Only available via MVC. Supports the use of the HTTP Range header to retrieve part of the log file’s content.
metrics Shows ‘metrics’ information for the current application.
mappings Displays a collated list of all @RequestMapping paths.
trace Displays trace information (by default the last few HTTP requests).



블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.

이클립스, Spring Starter Project 사용시

( New -> Spring  -> Spring Starter Project )

HTTP response code : 403 발생


1) eclipse 발생 에러 메시지


IO Exception : Server returned HTTP response code : 403 for URL :

http://start.spring.io



2) 검색 결과 답변들


You are getting a HTTP 403 Forbidden from the spring.io HTTP server. I can access your URL and download the archive - maybe you have a restrictive proxy or firewall in your way?


http://stackoverflow.com/questions/33378088/spring-tool-suite-error



3) 의심 증상


이클립스 내장 브라우저에서 접속시에 CAPCHA를 확인하는 페이지로 넘어간다.

아마도 spring.io의 특정 URL을 요청시에 redirect가 발생하면서 정상 처리가 안되는것 같다.



4) 확인 할것


사용중인 IP를 검색하고, blacklist에 등록되어 있는지 여부를 확인

http://whatismyipaddress.com/blacklist-check



블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


Spring Boot 소개 및 HelloWorld 작성


- Spring Boot Application 작성 하기

- Spring Boot(Jar)를 War 배포/전환 하기


Spring은 수년간 좋은 프레임웍이었지만 결점은 거의 없었다. 이 강좌에서, Spring Boot의 소개는 Spring Boot가 얼마나 결점들을 해결하면서 최신 현대적인 소프트웨어 아키텍처를 지원하는지를 보여준다.

저자는 2014년말경 부터 spring boot를 사용했으며, 최신버젼 1.3.3으로 이 문서를 작성했다.


What is Spring Boot ?

한 문장으로, Spring Boot는 Spring Framework에서 XML Configuration을 빼고, 통합된 서버를 제공한다.


Spring Boot Components


- Spring Boot Auto Configure

스프링 프로젝트를 다양하게 자동 구성하는 모듈. Batch, Data JPA, Hibernate, JDBC등의 프레임웍을 감지할 수 있다. 감지하게 되면, 자동 구성을 하고, (생성된) 프레임웍은 다소 필수적인 기본(구성)값을 갖는다.

- Spring Boot Core ,  Spring Boot CLI ,  Spring Boot Actuator

이 프로젝트가 추가 되면, 어플리케이션을 확실하게 기업 특성(보안, 지표, 기본 에러 페이지등)이 가능하게 한다.

- Spring Boot Starters ,  Spring Boot Tools


How to use Spring Boot


다른 글에서 어떻게 사용하고 어떻게 Spring Boot를 실행하는지를 보여주겠지만, 여기서는

아래 절차를 따라하는 것이 필요하다.


- 초기 설정을 생성하기 위해 스프링 초기화를 사용할 수 있다.

  : start.spring.io를 방문하거나 이클립스/IDEA에서 쓸 수있는 STS(Spring Tool Suite)를 사용해서 Spring Boot Starters를 선택한다.

  : start.spring.io를 사용하게 되면, zip파일을 다운로드해야 하고, workspace를 구성해야한다.


- 빌드Tool 로써 Maven 또는 Gradle를 선택할 수 있다.

- 필요한 code를 추가한다.

- mvn clean package를 사용하거나 이클립스/IDEA에서 빌드하고 jar를 생성하라.

- 기본으로 JAR는 통합 Tomcat server에 포함되고, JAR를 실행하므로써, 프로그램을 사용할 수 있다.


http://www.adeveloperdiary.com/java/spring-boot/an-introduction-to-spring-boot/



How to Create Spring Boot Application Step By Step


1) Create Spring Boot Application using start.spring.io 

- 선택 : Web(필수), Actuator(옵션)

옵션 선택후에 Generate Project를 누르면, 프로젝트가 다운로드 시작된다.

다운로드 완료후에 풀고, import를 한다.



* Eclipse에서 생성시 선택 화면

* Dependencies는 필요한 부분을 선택


2) Controller 작성 및 실행


@RestController
public class HelloRestController {


    @RequestMapping("/")
    public String index() {

         return "helloworld!";
    }

}

3) Run Spring Boot Application in Eclipse ( Run As -> Spring Boot App )




* 실행 오류 Dependencies에서 DB(MySQL, PostgreSQL)를 선택후에 설정을 하지 않는 

경우에는 다음과 같은 에러가 발생한다.

***************************
APPLICATION FAILED TO START
***************************

Description:

Cannot determine embedded database driver class for database type NONE


- application.properties에 아래와 같은 항목과 알맞게 우측 내용을 채워야 한다.

#DataSource settings : set here configuration for the database connection
#spring.datasource.url=
#spring.datasource.username=
#spring.datasource.password=
#spring.datasource.driver-class-name=org.postgresql.Driver



* Spring Boot,  jar -> war 배포로 변경


- Spring Boot Application -> Tomcat에 war 배포 하기


1) Application을 SpringBootServletInitializer으로 extends한다.

-- org.springframework.boot.context.web.SpringBootServletInitializer

-- org.springframework.boot.web.support.SpringBootServletInitializer

@SpringBootApplication
public class Application extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }

    public static void main(String[] args) throws Exception {
        SpringApplication.run(Application.class, args);
    }

}

2) pom,xml에서 war로 packing를 변경한다

<packaging>war</packaging>

3) pom.xml에서 tomcat dependency를 추가한다. ( spring-boot-starter-tomcat )

<dependencies>
    <!-- … -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
    <!-- … -->
</dependencies>

- 추가후 Maven -> Update Project 실행 필요


* 실행 오류 : The selection cannot be run on any server.


- tomcat server선택시에 상단의 붉은색 메시지 부분을 확인 후에 해제

 해제는 Project Facets


( start.spring.io 의 default설정 값으로 보임 )


참고 : 

http://www.adeveloperdiary.com/java/spring-boot/create-spring-boot-application-step-step/ ,

 [블로그개발_01] STS로 Spring Boot 웹 프로젝트 시작하기


http://camon85.blogspot.co.id/2015/12/spring-boot-war.html

Spring Boot war배포


http://stackoverflow.com/questions/35702975/how-to-deploy-a-simple-spring-boot-with-gradle-build-system-to-apache-tomcat

How to deploy a simple Spring Boot (with Gradle build system) to Apache Tomcat (real server, not embed server)?

package hello;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

}
package hello;

public class Greeting {

    private final long id;
    private final String content;

    public Greeting(long id, String content) {
        super();
        this.id = id;
        this.content = content;
    }

    public long getId() {
        return id;
    }

    public String getContent() {
        return content;
    }

}
package hello;

import java.util.concurrent.atomic.AtomicLong;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class GreetingController {

    private static final String template = "Hello, %s";
    private final AtomicLong counter = new AtomicLong();

    @RequestMapping("/greeting")
    public Greeting greeting(@RequestParam(value = "name", defaultValue = "World") String name) {
        return new Greeting(counter.incrementAndGet(), String.format(template, name));
    }

}


http://stackoverflow.com/questions/32571437/why-am-i-getting-project-facet-cloud-foundry-standalone-application-version-1-0

Why am I getting “Project facet Cloud Foundry Standalone Application version 1.0 is not supported”?



블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


Spring 4 MVC , Apache Tiles 3


Apache Tiles 3와 Spring MVC의 통합과 Bootstrap 적용 예제



1. 실행 화면


2. 사이트 URL

http://www.techyari.in/2015/06/spring-mvc-and-apache-tiles-3-integration-tutorial-with-example.html


블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


Maven Project  Add Dependency

( maven-archetype-webapp )



1)  Search : 일부 결과를 찾지 못할때, not found

증상 :  (!) Index downloads are disabled, search result may be incomplete



해결책 :

Windows->Preferences->Maven

[v] Download repository index updates on startup


참고 정보 :

http://stackoverflow.com/questions/14059685/eclipse-maven-search-dependencies-doesnt-work



2) Search : 결과가 없을때, no result

증상 :  검색 결과가 나오지 않는 경우에는 리셋이 필요 ( 이클립스 종료후에 )


해결책 :

프로젝트 폴더의 아래 폴더 하위 디렉토리를 삭제

( .metadata\.plugins\org.eclipse.m2e.core\nexus )





* Browsing and Manipulating Maven Repositories...

https://books.sonatype.com/m2eclipse-book/reference/repository-sect-repo-view.html



3) 'Full Index Enabled' , 'Rebuild Index' -> 'Global Repositories'

- Window->Show View->Other->Maven->Maven Respositories





블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


Admin LTE


https://almsaeedstudio.com/


- 오픈 소스

- 관리자 대시보드, 제어판 테마 ( 반응형, 재사용, 공통 컴포넌트 )

- Bootstrap 3 , jQuey 1.11 +,  Plugins

- Browser Support : IE9+, Firefox/Safari/Chrome/Opera(Latest)


- 미리보기 , https://almsaeedstudio.com/preview


- 디렉토리 구조


- Plugins


- 기본 구성 샘플 : index.html



index.html


블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,
노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.


이클립스(Eclipse)에 Gradle 프로젝트 생성


- Eclipse Version : Neon


1. Gradle Plugin 설치(Install) 하기


- Buildship Gradle Integration 1.0 , by the Eclipse Foundation



직접 다운로드 Gradle (for local installation) 

: https://gradle.org/gradle-download/ --> 인터넷 환경이 열악한 경우에..



2. Gradle 프로젝트 생성하기


http://qiita.com/grachro/items/d1ebad3857a794895426방법4


Eclipse 프로젝트가 배포하고있는 플러그인 때문에 Eclipse에서 사용하려면 가장 편리합니다.  생성 된 프로젝트의 구성은 gradle 명령으로 생성 한 경우와 거의 동일합니다





블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,