반응형

maven 스프링 프로젝트에 외부 라이브러리를 추가하려고 함.

1. lib폴더 아래에 외부에서 가져온 jar 파일을 위치시킴.

2. pom.xml 파일의 dependency 부분에 아래처럼 내용을 추가해준다.

<dependency>
	<groupId>barcodes</groupId> <!--이름-->
	<artifactId>barcodes</artifactId> <!--이름-->
	<version>7.2.2</version> <!--버전-->
	<scope>system</scope> <!--scope-->
    	<!--파일위치-->
	<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/barcodes-7.2.2.jar</systemPath> 
</dependency>

아니면 이렇게...

<dependency>
	<groupId>org.apache.tika</groupId>
	<artifactId>tika-core</artifactId>
	<version>2.8.0</version>
</dependency>

 

 

3. Eclipse의 경우 pom.xml 저장

프로젝트 우클릭 > Maven > Update Project 


Maven 의존성의 범위에 관해서는 아래 페이지를 참고하였음..

 

Maven – Introduction to the Dependency Mechanism

Introduction to the Dependency Mechanism Dependency management is a core feature of Maven. Managing dependencies for a single project is easy. Managing dependencies for multi-module projects and applications that consist of hundreds of modules is possible.

maven.apache.org

 

Dependency Scope

  • compile
    아무 것도 지정되지 않은 경우 사용되는 기본 범위.
    모든 클래스 경로에서 사용가능함.
  • provided
    런타임시에는 포함X, 컴파일 시점에만 포함됨. runtime시에 JDK나 컨테이너가 dependency를 제공할 것으로 간주하여 런타임시에는 classpath에 추가되지 않음.
  • runtime
    컴파일에는 포함X, 런타임과 test 시에만 포함됨.
  • test
    테스트 컴파일 및 실행 단계에만 포함
  • system
    JAR의 위치를 명시해야함. 항상 사용가능하며 레포지토리가 아닌 외부에서 찾음
  • import
    <dependencyManagement> 부분에서만 사용됨.     
반응형
반응형

라이브러리에 jar을 추가하려고 ... 했더니 lib 디렉토리도 못찾고...

Maven Dependencies에도 수동으로 paste로 추가하려 했더니 안 됨... ㅠ ㅠ 

Maven의 경우 pom에서 의존성관리를 한다고 함 ! 그래서 pom.xml에서 추가해주면 된다고 함

 

1. pom.xml

dependencies 밑에 이렇게 추가해주었음 

 

<groupId>임의의 이름</groupId>

<artifactId>버전 지우고 jar 파일명</artifactId>

<version>버전 </version>

 

2. 추가 후 저장하니까 에러가 뜨는거임.. 그래서 저 표시된 폴더에 jar파일을 수동으로 추가해줌 

추가된 dependency 내용을 지웠다가 다시 적고 저장하니까 이제 됨~!~!~! 

반응형

+ Recent posts