본문 바로가기
목차
maven

메이븐강의 12강 - mvn install : 내가 만든 라이브러리 설치하기

by 지각생 2021. 12. 27.
728x90

유툽 뉴렉처님 강의 시청후 복습 자료임

 

생성

next

finish

  <properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
  </properties>

 

저장 후 메이븐 업데이트 ㄱ

class추가

 

package com.newlecture.examlib.entity;

public class Exam {
private int kor;
private int eng;
private int math;

public int total() {
return kor + eng + math;
}

public Exam() {
// TODO Auto-generated constructor stub
}

public Exam(int kor, int eng, int math) {
super();
this.kor = kor;
this.eng = eng;
this.math = math;
}

public int getKor() {
return kor;
}

public void setKor(int kor) {
this.kor = kor;
}

public int getEng() {
return eng;
}

public void setEng(int eng) {
this.eng = eng;
}

public int getMath() {
return math;
}

public void setMath(int math) {
this.math = math;
}

@Override
public String toString() {
return "Exam [kor=" + kor + ", eng=" + eng + ", math=" + math + "]";
}

}

 

이 라이브러리를 다른 곳에서 쓰게 하려함.

 

메이븐 명령어 단계 중 install이란 단계가 있음.

이것을 이용해서 이렇게 jar파일 만들어서 로컬 repository저장소에 가져다 둘 수 있으나.

 

더 편한 방법 있다.

 

6. Maven install

 

콘솔창에서 빌드 성공 볼수 있음( 강의 영상)

 

나는 빌드 실패~!

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project examlib: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

 

문제 는 JDK파일이 없어서 인듯 하다 아래 링크 참고하여 해결해보자.

https://mainia.tistory.com/5629

 

스프링 (Spring Boot) 메이븐 배포시 No Compiler is provided in this environment 에러

스프링 (Spring Boot) 메이븐 배포시 No Compiler is provided in this environment 에러 환경: Eclipse 메이븐을 통해 배포할 때 다음과 같은 에러가 난다면 자바 실행 도구에 문제가 생긴 것입니다. 이클립스에..

mainia.tistory.com

이클립스에는 기본적으로 자바 실행 도구가 JRE(Java Runtime Environment) 로 연결이 되어 있습니다. 에러 해결을 위해서는 JRE 가 아닌 JDK(Java Development Kit) 로 변경해야 합니다. JDK 에는 프로그래밍에 필요한 컴파일러 등이 포함되어 있기 때문입니다. Maven 배포는 JDK 가 필요합니다.

 

 

빌드 성공하고 나면 다른 프로젝트로 가서

디펜던시 Add눌러도 되고

해도 똑같다.

 

그런데

 

여기서 검색해서 목록 나오려면

 

 

로컬 저장소와

원격 저장소 중

 

로컬 저장소에서 인덱스 검색을 해서 방금 인스톨한 녀석을 등록해 줘야 한다.

리빌드 인덱스 해서 완료되면

로컬 저장소에서 아까 인스톨한 뉴렉처를 볼수 있다.

이렇게 해야 검색이 가능해진다.

선택

 

 

프로젝트가 포함된 라이브러리를 가져오면 저런 폴더형태 나옴.

다른 이클립스에서 쓰면 아이콘이 톰캣처럼 보여진다.

 

임포트 가능해진다.

쨔잔

다른사람과 쓰려면 원격 저장소로 디플로이? 해야한다.

메이븐에서 많이 쓰는 단계

-컴파일

-테스트

-패키지

-인스톨 : 로컬 저장소에 인스톨

-디플로이 : 원격 저장소에 복사?

디플로이 할때는 메이븐에 계정이 있어야 한다.

다음시간에 계속

 

https://www.youtube.com/watch?v=2fyQm_gfnHk&list=PLq8wAnVUcTFWRRi_JWLArMND_PnZM6Yja&index=12 

 

728x90

댓글