[SpringBoot] 설정하기

🐷Jinie (juniorDeveloper)·2021년 1월 4일
1

SpringBoot

목록 보기
2/11
  1. src/main/java : 일반적인 자바 프로그램 작성
  2. src/main/resources : 자바 소스가 아닌 XML 이나 프로퍼티 파일 작성
    1) static : 이름 그대로 HTML 같은 정적인 웹 소스가 저장
    2) templates : 타임리프 같은 템플릿 기반의 웹리소스 저장
    3) application.properties : 프로젝트 전체에서 사용할 프로퍼티
  3. src/test/java : JUnit 기반 테스트

1. 기본클래스 실행하기

2. 포트설정

Description:
Web server failed to start. Port 8080 was already in use.

  • 8080포트를 이미 사용하고 있기 때문에 포트를 설정해줘야한다.
    server.port=8085

  • application.porperties 에서 server.port=8085로 설정완료
    o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8085 (http)

    3. WebApplicationType.NONE 으로 실행

 package com.rubypaaper;

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

@SpringBootApplication //스프링부트로 만든 애플리케이션의 시작클래스 정의
public class Chapter01Application {

	public static void main(String[] args) {
		//SpringApplication.run(Chapter01Application.class, args);
		// WebApplicationType.NONE  설정하면 자바 애플릿으로 실행됨.
		SpringApplication application =
				new SpringApplication(Chapter01Application.class);
		application.setWebApplicationType(WebApplicationType.NONE);
		application.run(args);
	}
}

  • 포트정보없이 실행

4. WebApplicationType.SERVLET 실행

package com.rubypaaper;

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

@SpringBootApplication //스프링부트로 만든 애플리케이션의 시작클래스 정의
public class Chapter01Application {

	public static void main(String[] args) {
		//SpringApplication.run(Chapter01Application.class, args);
		// WebApplicationType.NONE  설정하면 자바 애플릿으로 실행됨.
		SpringApplication application =
				new SpringApplication(Chapter01Application.class);
		application.setWebApplicationType(WebApplicationType.SERVLET);
		application.run(args);
	}

}

5. application.properties 한글설정

  • preferences -> Content Types ->Text -> Java Properties File -> Spring Properties File -> Default encoding : UTF-8

profile
ᴘᴇᴛɪᴛs ᴅᴇ́ᴠᴇʟᴏᴘᴘᴇᴜʀ. ᴘʀᴏɢʀᴀᴍᴍᴀᴛɪᴏɴ = ᴘʟᴀɪsɪʀ 💕

0개의 댓글