맥북에어 m1 스프링 레거시 셋팅

공부는 혼자하는 거·2021년 8월 21일
1

환경

목록 보기
6/23

STS 설치

https://spring.io/tools/

위 링크에서 맥 OS 버전을 다운받는다. (sts4 버전) 기본 자바랑 font는 설치완료와 환경변수까지 다 셋팅해놨다고 전제하겠다.

Spring Legacy && JS 지원 플러그인

sts4는 레거시를 지원하지 않기 때문에.. eclipse marketplace에서 아래 버전을 설치한다.

그리고 현재 sts에서는 자바스크립트 파일 자동완성등을 지원하지 않기 때문에.. 아래 버전도 다운

*.js 파일을 추가해주고, Generic Text Editor를 default로 해서 위로 올려준다.

폰트 && 문자 인코딩 설정


D2Coing 폰트로 설정.. 모든 인코딩은 UTF-8로

Lombok 설치

https://projectlombok.org/download

lombok 다운 받고 다운로드 받은 폴더에서 터미널 열고 @

java -jar lombok.jar


install/update 클릭

Theme 적용


눈 아프니까..

기타..

  • mybatis를 사용하고 계신 분들은 mapper 또는 dao 측에서 바로 쿼리를 작성한 xml파일로 바로 넘어갈수 있게 하는 플러그인 입니다.

  • 단축키 : control + clickc!

Quick Search for Eclipse

  • 파일 쉽고 빠르게 찾을 수 있는 플러그인

  • 입력한 텍스트가 포함되는 모든 파일을 빠르게 써치해준다.

  • 단축키 : control + shift + L

  • spring 플러그인을 사용하시는 분이라면 안하셔도 됩니다.

  • spring 플러그인 사용자는 단축키가 변경된것 같습니다. (ctrl+ alt + shift + L )

Spring Legacy 시작

open perspective spring 으로 열기

Tomcat 설치와 연동

brew search tomcat
brew install tomcat@9 //9버전
arch -arm64 brew install tomcat@9//Rosetta2 관련 에러 발생 시
brew list //잘 설치되었는지 확인

설치가 끝났으면 실행을 시켜줘야겠지?


m1은 기본설치경로가 opt 이기 때문에.. 이 경로로 들어가자.

./catalina start //톰캣 구동
./catalina stop //중지

프로젝트 우클릭 → Run as → Run on server

xml 셋팅

root-context.xml

<?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 https://www.springframework.org/schema/beans/spring-beans.xsd">
	
	<!-- Root Context: defines shared resources visible to all other web components -->
		
</beans>

servlet-context.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:beans="http://www.springframework.org/schema/beans"
	xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd
		http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">

	<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
	
	<!-- Enables the Spring MVC @Controller programming model -->
	<annotation-driven />

	<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
	<resources mapping="/resources/**" location="/resources/" />

	<!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
	<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>
	
	<context:component-scan base-package="com.example.kang" />
	
	
	
</beans:beans>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns="http://xmlns.jcp.org/xml/ns/javaee"
	xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
	id="WebApp_ID" version="3.1">

	<!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>/WEB-INF/spring/root-context.xml</param-value>
	</context-param>
	
	<!-- Creates the Spring Container shared by all Servlets and Filters -->
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>

	<!-- Processes application requests -->
	<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>
	
<!-- 	
	<multipart-config>
			<location>C:\\upload\\temp</location>
			<max-file-size>20971520</max-file-size> 1MB * 20
			<max-request-size>41943040</max-request-size>40MB
			<file-size-threshold>20971520</file-size-threshold> 20MB
		</multipart-config> -->
		
</servlet>

	<servlet-mapping>
		<servlet-name>appServlet</servlet-name>
		<url-pattern>/</url-pattern>
	</servlet-mapping>
	<filter>
		<filter-name>encoding</filter-name>
		<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
		<init-param>
			<param-name>encoding</param-name>
			<param-value>UTF-8</param-value>
		</init-param>
	</filter>

	<filter-mapping>
		<filter-name>encoding</filter-name>
		<servlet-name>appServlet</servlet-name>
	</filter-mapping>
</web-app>

실행 결과

프로젝트 우클릭 → run as server

확실히 내장톰캣이 편하긴 해..

Docker Oracle 11g 설치

docker search oracle-xe //여러가지 이미지가 나오는데
docker pull ~~~ //그 중 별 가장 많이 받은 거 다운
docker images //이미지가 다운로드 되었는지 확인

docker run --name oracle11g -d -p 9090:8080 -p 1521:1521 oracleinanutshell/oracle-xe-11g

docker stop oracle11g-test //컨테이너 중지
  • run: 컨테이너 실행
  • -name oracle11g: 컨테이너 이름을 oracle11g로 설정
  • d: 백그라운드에서 컨테이너를 실행시키는 옵션 (detached mode)
  • p: 호스트와 컨테이너의 포트 연결
  • v {path}: 호스트와 컨테이너의 디렉토리 연결. -v 옵션을 추가하면 컨테이너 종료 시 데이터를 외부에 저장할 수 있다. (사용 안함)

Oracle XE 를 설치하게 되면 기본 접속 포트인 1521 외에 8080 포트도 열리게 된다. 8080은 쓸 거기 때문에 포트변경을 해주자..

The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested

https://hub.docker.com/r/oracleinanutshell/oracle-xe-11g

경고 발생!

프로세스는 돌아가긴 하는데, arm/v8 용 아키텍처 이미지가 아니라서 발생한 경고같다. 굉장히 찜찜한데 뭐 별수가 있나.. 다른 이미지도 다 지원 안 한다.. 그냥 해보자..

https://stackoverflow.com/questions/65456814/docker-apple-silicon-m1-preview-mysql-no-matching-manifest-for-linux-arm64-v8

https://nashu.dev/posts/install-oracle

SQL Devloper 설치

기본으로 제공하는 sql plus보다 확장기능이 많다.

https://www.oracle.com/tools/downloads/sqldev-downloads.html

MAC OS 다운 받고 여는데 아래와 같은 에러 발생

can’t be opened because Apple cannot check it for malicious software.

https://jlog1016.tistory.com/50

open anyway 클릭, 그리고 application에 옮긴다음 다시 open 하면 된다.

정식 jdk가 아닌 open jdk를 써서 생긴 문제이다..

https://arno-schots.medium.com/javafx-error-with-oracle-sql-developer-on-mac-os-bb27de11a63a

현재 나의 자바 버전을 확인

ls -al /Library/Java/JavaVirtualMachines/

https://www.oracle.com/java/technologies/javase-jdk11-downloads.html

정식 오라클 자바버전 11 을 다운받자.

그런 다음 홈 디렉토리의 숨겨진 폴더에 있어야하는 다음 파일을 열고 편집


우클릭 getinfo로 경로를 복사해


파일 열고..

주석 해제 후 SetJavaHome 경로 맵핑

sql developer 재시작하면 오류 안 생길 거다.

https://shanepark.tistory.com/87

접속 시 ORA 12505 에러 발생!

컨테이너 스톱시키고 삭제, 이미지도 삭제한 후 다시 위처럼 이미지를 다운받는다..

The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested

아예 지원자체를 안 하는가..... 도저히 방법을 모르겠네.... buildx 다시 도커파일 만들고 생지랄을 떨어도 안 됨...

진짜 개 삽질 많이 한다. DB설정으로 하루가 날라갔네..

암튼 포기!!!!! 걍 mysql 로 해야겠다..

추가

https://t1.daumcdn.net/cfile/tistory/9926053359A3D2B025

좌측 상단에 있는 [Package Explorer]에서 방금 생성한 MVC 프로젝트 폴더를 마우스 오른쪽 클릭합니다. 그리고 [Build Path] ▶ [Configure Build Path]를 선택합니다.

https://t1.daumcdn.net/cfile/tistory/99A7123359A3D2B12D

[Libraries] 탭을 선택하고 [JRE System Library]를 선택하고 [Edit]를 누릅니다. 현재 최신버전의 Spring STS라도 [JRE System Library]는 기본적으로 [JavaSE-1.6]으로 되어있습니다.

https://t1.daumcdn.net/cfile/tistory/9933E23359A3D2B217

다음에 뜨는 창에서 [Workspace default JRE]를 선택해줍니다. 현재 자신에 컴퓨터에 설치된 JDK가 자동으로 선택됩니다. 그다음 [Finish]를 누릅니다.

https://t1.daumcdn.net/cfile/tistory/994B003359A3D2B414

https://hanazuou.tistory.com/158

profile
시간대비효율

1개의 댓글

comment-user-thumbnail
2022년 10월 16일

안녕하세요.\
STS에서 레거시 플러그인을 설치할때
Cannot complete the provisioning operation. Please change your selection and try again. See below for details.
이런 에러가뜨는데 혹시 해결방법을 알고 계신가요?? 이거 하나때매 포멧했는데 아직도 뜨네요...

답글 달기