ETC 2020. 4. 16. 00:22

(공감과 댓글 하나는 글쓴이에게 큰 힘이 됩니다.)

 

프로그램을 다운받을 때 운영체제별로 프로그램이 나뉘어 있는 것을 본 적이 있을 것이다. 자신의 운영체제에 맞는 파일을 다운받아야 하는데, 자신의 운영체제 버전을 간단하게 확인할 수 있다.

 

1. 제어판 - 시스템 또는 내 PC 마우스 우클릭 - 속성을 통해 시스템 메뉴에 들어간다.

2. Windows 버전시스템 종류를 통해 자신의 운영체제 버전을 확인할 수 있다.

'ETC' 카테고리의 다른 글

VMware 설치  (0) 2020.04.17
VirtualBox 설치  (0) 2020.04.17
Windows Git 설치  (0) 2020.04.07
posted by DevMoomin
:
Spring/Solve 2020. 4. 15. 23:52

(공감과 댓글 하나는 글쓴이에게 큰 힘이 됩니다.)

 

서버 실행 시 아래와 같이 The Specified JRE installation does not exist라는 에러가 발생하는 경우가 있다. 해당 에러는 서버에 JRE 경로가 잘못 지정되어있어서 발생하는 에러이다.

 

1. 상단의 Windows - Preferences 클릭

2. 좌측 트리의 Server - Runtime Environments에서 Tomcat 선택 후 Edit 클릭

3. JRE 버전을 선택하고 Finish 클릭

4. Apply and Close를 클릭하여 설정 적용

posted by DevMoomin
:
Spring/Study 2020. 4. 15. 23:01

(공감과 댓글 하나는 글쓴이에게 큰 힘이 됩니다.)

 

1. Eclipse 실행 후 Project Explorer 영역에서 마우스 우클릭 - New - Other... 클릭

2. spring을 검색해서 Spring Legacy Project 선택 후 Next 클릭

3. Project name을 입력하고, Spring MVC Project 선택 후 Next 클릭

4. Yes 클릭

5. package name 입력 후 Finish 클릭 (package name은 2단계 이상으로 해야 함)

6. 관련파일 다운로드 등이 완료될 때까지 대기(우측 하단에서 진행사항 확인)

7. 프로젝트 폴더 마우스 우클릭 - Run As - Run On Server를 클릭

8. Finish 클릭

9. 정상적으로 실행되는 것 확인

posted by DevMoomin
:
Algorithm/Problem Solving 2020. 4. 14. 16:43

(공감과 댓글 하나는 글쓴이에게 큰 힘이 됩니다.)

 

문제 링크

- https://www.acmicpc.net/problem/10844

 

사용 알고리즘

- DP

 

풀이

- d[i][j] = i자리 계단수의 개수, i번째 자리의 수는 j

1) 1 <= j <= 8 일 때,

    d[i][j] = d[i - 1][j - 1] + d[i - 1][j + 1]

2) j = 0 일 때,

    d[i][j] = d[i - 1][j + 1]

3) j = 9 일 때,

    d[i][j] = d[i - 1][j - 1]

 

소스 코드

- https://github.com/moomini/algorithm/blob/master/boj/10844.cpp

#include <cstdio>

 

int d[103][10];

 

int main(void) {

    int n; scanf("%d"&n);

    for (int i = 1; i <= 9++i) d[1][i] = 1;

    for (int i = 2; i <= n; ++i) {

        for (int j = 0; j <= 9++j) {

            if (j >= 1) d[i][j] += d[i - 1][j - 1];

            if (j <= 8) d[i][j] += d[i - 1][j + 1];

            d[i][j] %= 1000000000;

        }

    }

    int ans = 0;

    for (int i = 0; i <= 9++i) {

        ans += d[n][i];

        ans %= 1000000000;

    }

    printf("%d\n", ans);

    return 0;

}

Colored by Color Scripter

cs

'Algorithm > Problem Solving' 카테고리의 다른 글

[BOJ/11055] 가장 큰 증가 부분 수열  (0) 2020.04.18
[BOJ/11053] 가장 긴 증가하는 부분 수열  (0) 2020.04.17
[BOJ/2156] 포도주 시식  (0) 2020.04.17
[BOJ/9465] 스티커  (0) 2020.04.16
[BOJ/11057] 오르막 수  (0) 2020.04.16
posted by DevMoomin
:
Spring/Install 2020. 4. 14. 14:56

(공감과 댓글 하나는 글쓴이에게 큰 힘이 됩니다.)

 

STS(Spring Tool Suite)란 이클립스에서 스프링 기반의 애플리케이션 개발을 지원하는 개발 환경을 의미한다.

STS 설치 전, 웹 컨테이너인 Apache Tomcat이 설치되어 있어야 한다.

 

Apache Tomcat 설치 : https://devmoomini.tistory.com/43

 

1. 이클립스 상단의 Help - Eclipse Marketplace...를 클릭

2. sts를 검색해서 Spring Tools 3 Add-On for Spring Tools 4 3.9.12.RELEASE의 Install을 클릭

3. 모두 체크된 상태에서 Confirm 클릭

4. I accept the terms of the license agreements를 선택하고, Finish 클릭

5. Restart Now를 클릭하여 이클립스를 재실행하면 설치 완료

'Spring > Install' 카테고리의 다른 글

이클립스(Eclipse) Apache Tomcat 설정  (0) 2020.04.20
Apache Tomcat 설치  (0) 2020.04.07
Maven 설치  (0) 2020.04.07
posted by DevMoomin
:
Spring/Study 2020. 4. 14. 11:28

(공감과 댓글 하나는 글쓴이에게 큰 힘이 됩니다.)

 

Model1

JSP, Service, DAO를 하나의 파일로 처리하는 방식으로, 하나의 파일에서 모든 개발이 이루어지므로 개발 속도가 빠르지만 유지보수가 어렵다.

 

 

Model2

Controller, Service, DAO, View로 각각의 기능을 모듈화 하는 MVC 방식으로, 스프링에서 사용하는 방식이다. 특정 파일만 수정하면 되므로 유지보수가 수월하다.

 

 

스프링 MVC 프레임워크 설계구조

- HandlerMapping : 적합한 Controller를 선택

- HandlerAdapter : 해당하는 Controller 내에서 가장 적합한 메소드를 선택

- ViewResolver : 가장 적합한 JSP 파일 선택

 

DispatcherServlet 설정

JSP 웹 설정파일인 web.xml에 사용자의 모든 요청을 받기 위해 root를 의미하는 / 로 url을 매핑한다. 스프링 설정파일을 설정하면 스프링 컨테이너가 만들어지는데, 스프링 컨테이너에 HandlerMapping, HandlerAdapter, ViewResolver가 자동으로 생성되므로 개발자는 Controller와 View만 작업해주면 된다. (스프링 설정 파일을 설정하지 않으면 자동으로 설정해줌)

<servlet>
    <servlet-name>appServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
 
<servlet-mapping>
    <servlet-name>appServlet</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>
cs

 

Controller 객체 - @Controller

스프링 설정 파일에 <annotation-driven /> 태그를 넣어주면 스프링 컨테이너를 사용하기 위한 여러 기능을 하는 클래스들이 빈(Bean) 객체로 스프링 설정 파일에 존재하게 된다. 컨트롤러로 사용할 클래스 이름 앞에 @Controller 어노테이션을 명시해준다.

servlet-context.xml

<annotation-driven />
cs

HomeController.java

@Controller
public class HomeController {
 
}
cs

 

Controller 객체 - @RequestMapping

설정한 URL로 매핑이 되도록 한다.

@RequestMappint("/success")
public String success(Model model) {
 
    return "success";
}
cs

 

Controller 객체 - Model 타입의 파라미터

개발자는 Model 객체에 데이터를 담아서 DispatcherServlet에 전달할 수 있다. DispatcherServlet에 전달된 Model 데이터는 View에서 가공되어 클라이언트에게 응답처리된다.

model.setAttribute("tempData""model has data!!");
cs

 

@RequestMapping("/success")
public String success(Model model) {
 
    return "success";
}
cs

 

View 객체

스프링 설정 파일에 InternalResourceViewResolver라는 빈(Bean) 객체를 생성하는데, InternalResourceViewResolver는 prefix, 리턴 값, suffix 값을 합쳐서 적절한 View 파일로 매핑하는 역할을 한다.

/WEB-INF/views/success.jsp

@RequestMapping("/success")
public String success(Model model) {
 
    return "success";
}
cs

 

<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <beans:property name="prefix" value="/WEB-INF/views/" />
    <beans:property name="suffix" value=".jsp" />
</beans:bean>

Colored by Color Scripter

cs

posted by DevMoomin
:
Spring/Study 2020. 4. 13. 17:10

(공감과 댓글 하나는 글쓴이에게 큰 힘이 됩니다.)

 

하나의 설정 파일로 관리를 하다 보면 소스가 길어지면서 유지보수가 어려워질 수 있다. 따라서 설정 파일을 기능별로 분리해서 사용하는 것이 효율적이다.

 

배열 형식으로 넣어주는 방법

MainClass.java

public class MainClass {
    public static void main(String[] args) {
        AnnotationConfigApplicationContext ctx = 
                new AnnotationConfigApplicationContext(MemberConfig1.class, MemberConfig2.class, MemberConfig3.class);
        
        EMSInformationService informationService = ctx.getBean("informationService", EMSInformationService.class);
        informationService.outputEMSInformation();
        
        ctx.close();    
    }
}
cs

 

@import 어노테이션을 사용하는 방법

MemberConfigImport.java

@Configuration
@Import({MemberConfig2.class, MemberConfig3.class})
public class MemberConfigImport {
    @Bean
    public StudentDao studentDao() {
        return new StudentDao();
    }    
}
cs

MainClass.java

public class MainClass {
    public static void main(String[] args) {
        AnnotationConfigApplicationContext ctx = 
                new AnnotationConfigApplicationContext(MemberConfigImport.class);
        
        EMSInformationService informationService = ctx.getBean("informationService", EMSInformationService.class);
        informationService.outputEMSInformation();
 
        ctx.close();    
    }
}

Colored by Color Scripter

cs

posted by DevMoomin
:
Spring/Study 2020. 4. 13. 16:05

(공감과 댓글 하나는 글쓴이에게 큰 힘이 됩니다.)

 

@Configuration 어노테이션은 JAVA 파일을 스프링 컨테이너로 사용하도록 명시해주는 어노테이션이다. 따라서 @Configuration 어노테이션을 통해 JAVA 파일이 스프링 컨테이너(xml) 역할을 하도록 할 수 있다. JAVA 파일에서는 @Bean 어노테이션을 사용하여 메소드로  빈(Bean) 객체를 생성한다.

 

bean

<?xml version="1.0" encoding="UTF-8"?>
 
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
         http://www.springframework.org/schema/beans/spring-beans.xsd">
 
    <bean id="studentDao" class="ems.member.dao.StudentDao" ></bean>
 
</beans>
cs

 

@Configuration
public class MemberConfig {
    @Bean
    public StudentDao studentDao() {
        return new StudentDao();
    }
}
cs

 

constructor

<?xml version="1.0" encoding="UTF-8"?>
 
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
         http://www.springframework.org/schema/beans/spring-beans.xsd">
 
    <bean id="registerService" class="ems.member.service.StudentRegisterService">
        <constructor-arg ref="studentDao" ></constructor-arg>
    </bean>
 
</beans>
cs

 

@Configuration
public class MemberConfig {
    @Bean
    public StudentRegisterService registerService() {
        return new StudentRegisterService(studentDao());
    }
}
cs

 

property

<?xml version="1.0" encoding="UTF-8"?>
 
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
         http://www.springframework.org/schema/beans/spring-beans.xsd">
 
    <bean id="dataBaseConnectionInfoDev" class="ems.member.DataBaseConnectionInfo">
        <property name="jdbcUrl" value="jdbc:oracle:thin:@localhost:1521:xe" />
        <property name="userId" value="scott" />
        <property name="userPw" value="tiger" />
    </bean>
 
</beans>
cs

 

@Configuration
public class MemberConfig {
    @Bean    
    public DataBaseConnectionInfo dataBaseConnectionInfoDev() {
        DataBaseConnectionInfo infoDev = new DataBaseConnectionInfo();
        infoDev.setJdbcUrl("jdbc:oracle:thin:@localhost:1521:xe");
        infoDev.setUserId("scott");
        infoDev.setUserPw("tiger");
        
        return infoDev;
    }
}
cs

 

list

<?xml version="1.0" encoding="UTF-8"?>
 
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
         http://www.springframework.org/schema/beans/spring-beans.xsd">
    
    <bean id="informationService" class="ems.member.service.EMSInformationService">
        <property name="developers">
            <list>
                <value>Cheney.</value>
                <value>Eloy.</value>
                <value>Jasper.</value>
                <value>Dillon.</value>
                <value>Kian.</value>
            </list>
        </property>
    </bean>
 
</beans>
cs

 

@Configuration
public class MemberConfig {
    @Bean
    public EMSInformationService informationService() {
        EMSInformationService info = new EMSInformationService();
        
        ArrayList<String> developers = new ArrayList<String>();
        developers.add("Cheney.");
        developers.add("Eloy.");
        developers.add("Jasper.");
        developers.add("Dillon.");
        developers.add("Kian.");
        info.setDevelopers(developers);
        
        return info;
    }
}
cs

 

map

<?xml version="1.0" encoding="UTF-8"?>
 
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
         http://www.springframework.org/schema/beans/spring-beans.xsd">
    
    <bean id="informationService" class="ems.member.service.EMSInformationService">
        <property name="administrators">
            <map>
                <entry>
                    <key>
                        <value>Cheney</value>
                    </key>
                    <value>cheney@springPjt.org</value>
                </entry>
                <entry>
                    <key>
                        <value>Jasper</value>
                    </key>
                    <value>jasper@springPjt.org</value>
                </entry>
            </map>
        </property>
    </bean>
 
</beans>
cs

 

@Configuration
public class MemberConfig {
    @Bean    
    public EMSInformationService informationService() {
        EMSInformationService info = new EMSInformationService();
        
        Map<StringString> administrators = new HashMap<StringString>();
        administrators.put("Cheney""cheney@springPjt.org");
        administrators.put("Jasper""jasper@springPjt.org");
        info.setAdministrators(administrators);
    
        return info;
    }
}

Colored by Color Scripter

cs

posted by DevMoomin
:
Spring/Study 2020. 4. 13. 15:25

(공감과 댓글 하나는 글쓴이에게 큰 힘이 됩니다.)

 

스프링 컨테이너가 생성되면 컨테이터 내부에서 빈(Bean) 객체가 생성되고, 빈(Bean) 객체들은 서로 의존 관계를 가지고 있다. 따라서 스프링 컨테이너와 빈(Bean) 객체의 생명주기는 동일하다.

 

인터페이스(Interface)를 이용하는 방법

BookDao.java

public class BookDao implements InitializingBean, DisposableBean {
    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("빈(Bean)객체 생성 단계");
    }
 
    @Override
    public void destroy() throws Exception {
        System.out.println("빈(Bean)객체 소멸 단계");
    }    
}
cs

 

init-method, destroy-method 속성을 이용하는 방법

appCtx.xml

<?xml version="1.0" encoding="UTF-8"?>
 
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
         http://www.springframework.org/schema/beans/spring-beans.xsd 
         http://www.springframework.org/schema/context 
         http://www.springframework.org/schema/context/spring-context.xsd">
 
    <context:annotation-config />
 
    <bean id="bookRegisterService" class="com.brms.book.service.BookRegisterService" 
    init-method="initMethod" destroy-method="destroyMethod"/>
</beans>
cs

BookRegisterService.java

public class BookRegisterService {
    public void initMethod() {
        System.out.println("BookRegisterService 빈(Bean)객체 생성 단계");
    }
    
    public void destroyMethod() {
        System.out.println("BookRegisterService 빈(Bean)객체 소멸 단계");
    }
}

Colored by Color Scripter

cs

posted by DevMoomin
:
Spring/Study 2020. 4. 12. 20:02

(공감과 댓글 하나는 글쓴이에게 큰 힘이 됩니다.)

 

@Qualifier

동일한 객체가 2개 이상인 경우, 스프링 컨테이너는 자동 주입 대상 객체를 판단하지 못해서 Exception을 발생시키는데, @Qualifier 어노테이션을 통해 주입할 객체를 명시함으로써 해결할 수 있다. (변수 이름과 Bean의 ID가 같은 경우 @Qualifier 어노테이션이 없어도 에러가 발생하지 않지만 추천하는 방식은 아니다.)

appCtx.xml

<?xml version="1.0" encoding="UTF-8"?>
 
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
         http://www.springframework.org/schema/beans/spring-beans.xsd 
         http://www.springframework.org/schema/context 
         http://www.springframework.org/schema/context/spring-context.xsd">
 
    <context:annotation-config />
 
    <bean id="wordDao" class="com.word.dao.WordDao" >
        <qualifier value="usedDao"/>
    </bean>
    <bean id="wordDao2" class="com.word.dao.WordDao" />
    <bean id="wordDao3" class="com.word.dao.WordDao" />
</beans>
cs

WordRegisterService.java

@Autowired
@Qualifier("usedDao")
private WordDao wordDao;
cs

 

의존객체 자동 주입 체크

자동 주입할 객체가 없는 경우 Exception이 발생하는데, required=false 속성을 통해 자동 주입할 객체가 없는 경우에는 주입하지 않도록 함으로써 Exception을 방지할 수 있다.

WordRegisterService.java

@Autowired(required=false)
private WordDao wordDao;
cs

 

@Inject

@Autowired처럼 의존객체를 자동으로 주입을 할 수 있지만, required 속성을 지원하지 않는다. @Qualifier 대신 @Named 어노테이션을 사용한다. (@Inject 보다 @Autowired를 더 많이 사용)

appCtx.xml

<?xml version="1.0" encoding="UTF-8"?>
 
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
         http://www.springframework.org/schema/beans/spring-beans.xsd 
         http://www.springframework.org/schema/context 
         http://www.springframework.org/schema/context/spring-context.xsd">
 
    <context:annotation-config />
    
    <bean id="wordDao1" class="com.word.dao.WordDao" />
    <bean id="wordDao2" class="com.word.dao.WordDao" />
</beans>
cs

WordRegisterService.java

@Inject
@Named(value="wordDao1")
private WordDao wordDao;

cs

posted by DevMoomin
: