maven-surefire-plugin 에러

Posted 2020. 7. 2. 18:22

githup에 올라온 프로젝트를 다운받아 빌드하려고 하는데, pom.xml 에서 아래와 같은 오류가 없어지지 않는다.

"Failure to transfer org.apache.maven.plugins:maven-surefire-plugin:pom:2.12.4 from https://repo.maven.apache.org/maven2 was cached in the local repository ... 중략 ..."

일반적으로 maven build 오류는 maven clean, maven update, maven install  과정을 통해서 대부분 사라지는데, 이번엔 아니다.

"mvn dependency::tree" 명령어를 command창에서 실행하고 나니 그제서야 오류가 사라졌다.

 

 



oracle jdbc driver는 기본적으로 maven 저장소를 지원하지 않는다.

때문에 로컬에 저장해 놓은 jdbc driver를 지정해서 가져오거나 maven 이 아닌 eclipse상에서 external jar 를 설정해야 한다.

maven설정은 다음과 같은 순서로 지정한다.


1. 먼저 maven이 설치되어 있어야 한다. (apache maven 다운받아서 압축해제)

 - path 설정여부는 옵션이다.

2. jdbc driver를 임의 디렉토리에 위치시킨다. (d:\dev\ojdbc6.jar)

3. maven install 명령어로 install 한다. path가 잡혀져 있지 않은 경우 {MAVEN_HOME}\bin 으로 이동한다.

\bin> mvn install:install-file -Dfile=d:/dev/ojdbc6.jar -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0 -Dpackaging=jar

4. pom.xml 설정

   <dependency>

            <groupId>com.oracle</groupId>

            <artifactId>ojdbc6</artifactId>

            <version>11.2.0</version>

   </dependency>

5. project > maven update 후 확인한다.





pom.xml 설정 팁 2가지 정리

1. 로컬환경과 운영환경 선택적으로 build배포하기

2. 웹서버에 배포될 정적 리소스를 제거하고 build 하기


첫번째로 profiles를 이용하여 로컬환경과 운영환경 선택적으로 build배포하기 입니다.

<profiles>

<profile>

<id>dev</id>

<activation>

<activeByDefault>true</activeByDefault>

</activation>

<properties>

<env>dev</env>

</properties>

</profile>

<profile>

<id>real</id>

<properties>

<env>real</env>

</properties>

</profile>

</profiles>

... 중략...

        <resources>

    <resource>

<directory>src/main/resources</directory>

    </resource>

    <resource>

  <directory>src/main/resources-${env}</directory>

    </resource>

</resources>

src/main/ 이하에 resources 관련 디렉토리를 아래와 같이 구분하여 정리합니다.

> main

    > java

    > resources

    > resources-dev

    > resources-real


두번째는 웹서버에 배포될 정적 리소스를 제거하고 build 하기입니다.

<plugins>

<!-- WAR 동적 파일 -->

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-war-plugin</artifactId>

<version>2.2</version>

<configuration>

    <warName>testBuild-was</warName>

    <warSourceExcludes>css/**,form/**,html/**,images/**,js/**,resource/**</warSourceExcludes>

</configuration>

</plugin>





« PREV : 1 : 2 : 3 : NEXT »