버전 비교

  • 이 줄이 추가되었습니다.
  • 이 줄이 삭제되었습니다.
  • 서식이 변경되었습니다.

...

코드 블럭
titlenexus.service
linenumberstrue
[Unit]252C
Description=nexus service
After=network.target

[Service]
Type=forking
LimitNOFILE=65536
ExecStart=/opt/nexus-3.29.2-02/bin/nexus start
ExecStop=/opt/nexus-3.29.2-02/bin/nexus stop
User=rootnexus
Restart=on-abort
TimeoutSec=600

[Install]
WantedBy=multi-user.target

...

코드 블럭
titlesettings.xml
linenumberstrue
<?xml version="1.0" encoding="UTF-8"?>
<settings   xmlns="http://maven.apache.org/SETTINGS/1.0.0"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <mirrors>
    <mirror>
      <id>Maven Repo<<id>maven-spring-public</id>
      <name>Maven Repo<<name>maven-spring-public</name>
      <url>http://192.168.33.10:8089/repository/spring-central/</url>
      <mirrorOf>central</mirrorOf>
    </mirror>
  </mirrors>
</settings>

...

  • IntelliJ라는 IDE 툴을 이용하여 spring boot starter 프로젝트를 생성한 후 Nexus repository에서 repository를 미러링 하여 jar 파일을 다운로드 받았습니다.
  • 이 때 저는 spring repository 만 추가되어 있기 때문에 다른 패키지들을 다운로드 할 때 에러가 발생합니다.
  • 그래서 실제로 maven install을할 install을 할 때는 이미 존재하는 maven-public repository를 이용했습니다.

...

코드 블럭
linenumberstrue
.. 생략

[INFO] Scanning for projects...
Downloading from Maven Repomaven-spring-public: http://192.168.33.10:8089/repository/spring-central/org/springframework/boot/spring-boot-starter-parent/2.4.2/spring-boot-starter-parent-2.4.2.pom
Downloaded from Maven Repomaven-spring-public: http://192.168.33.10:8089/repository/spring-central/org/springframework/boot/spring-boot-starter-parent/2.4.2/spring-boot-starter-parent-2.4.2.pom (8.6 kB at 83 kB/s)
Downloading from Maven Repomaven-spring-public: http://192.168.33.10:8089/repository/spring-central/org/springframework/boot/spring-boot-dependencies/2.4.2/spring-boot-dependencies-2.4.2.pom
Downloaded from Maven Repomaven-spring-public: http://192.168.33.10:8089/repository/spring-central/org/springframework/boot/spring-boot-dependencies/2.4.2/spring-boot-dependencies-2.4.2.pom (108 kB at 2.9 MB/s)
Downloading from Maven Repomaven-spring-public: http://192.168.33.10:8089/repository/spring-central/com/datastax/oss/java-driver-bom/4.9.0/java-driver-bom-4.9.0.pom
Downloading from Maven Repomaven-spring-public: http://192.168.33.10:8089/repository/spring-central/io/dropwizard/metrics/metrics-bom/4.1.17/metrics-bom-4.1.17.pom
Downloading from Maven Repomaven-spring-public: http://192.168.33.10:8089/repository/spring-central/org/codehaus/groovy/groovy-bom/2.5.14/groovy-bom-2.5.14.pom
Downloading from Maven Repomaven-spring-public: http://192.168.33.10:8089/repository/spring-central/org/infinispan/infinispan-bom/11.0.8.Final/infinispan-bom-11.0.8.Final.pom
Downloading from Maven Repomaven-spring-public: http://192.168.33.10:8089/repository/spring-central/com/fasterxml/jackson/jackson-bom/2.11.4/jackson-bom-2.11.4.pom
Downloading from Maven Repomaven-spring-public: http://192.168.33.10:8089/repository/spring-central/org/glassfish/jersey/jersey-bom/2.32/jersey-bom-2.32.pom
Downloading from Maven Repomaven-spring-public: http://192.168.33.10:8089/repository/spring-central/org/eclipse/jetty/jetty-bom/9.4.35.v20201120/jetty-bom-9.4.35.v20201120.pom
Downloading from Maven Repomaven-spring-public: http://192.168.33.10:8089/repository/spring-central/org/junit/junit-bom/5.7.0/junit-bom-5.7.0.pom
Downloading from Maven Repomaven-spring-public: http://192.168.33.10:8089/repository/spring-central/org/jetbrains/kotlin/kotlin-bom/1.4.21/kotlin-bom-1.4.21.pom
Downloading from Maven Repomaven-spring-public: http://192.168.33.10:8089/repository/spring-central/org/jetbrains/kotlinx/kotlinx-coroutines-bom/1.4.2/kotlinx-coroutines-bom-1.4.2.pom
Downloading from Maven Repomaven-spring-public: http://192.168.33.10:8089/repository/spring-central/org/apache/logging/log4j/log4j-bom/2.13.3/log4j-bom-2.13.3.pom
Downloading from Maven Repomaven-spring-public: http://192.168.33.10:8089/repository/spring-central/io/micrometer/micrometer-bom/1.6.3/micrometer-bom-1.6.3.pom
Downloading from Maven Repomaven-spring-public: http://192.168.33.10:8089/repository/spring-central/io/netty/netty-bom/4.1.58.Final/netty-bom-4.1.58.Final.pom
Downloading from Maven Repomaven-spring-public: http://192.168.33.10:8089/repository/spring-central/com/oracle/database/jdbc/ojdbc-bom/19.8.0.0/ojdbc-bom-19.8.0.0.pom
Downloading from Maven Repomaven-spring-public: http://192.168.33.10:8089/repository/spring-central/io/r2dbc/r2dbc-bom/Arabba-SR8/r2dbc-bom-Arabba-SR8.pom
Downloading from Maven Repomaven-spring-public: http://192.168.33.10:8089/repository/spring-central/io/projectreactor/reactor-bom/2020.0.3/reactor-bom-2020.0.3.pom
Downloading from Maven Repomaven-spring-public: http://192.168.33.10:8089/repository/spring-central/io/rsocket/rsocket-bom/1.1.0/rsocket-bom-1.1.0.pom
Downloading from Maven Repomaven-spring-public: http://192.168.33.10:8089/repository/spring-central/org/springframework/data/spring-data-bom/2020.0.3/spring-data-bom-2020.0.3.pom
Downloading from Maven Repomaven-spring-public: http://192.168.33.10:8089/repository/spring-central/org/springframework/spring-framework-bom/5.3.3/spring-framework-bom-5.3.3.pom
Downloading from Maven Repomaven-spring-public: http://192.168.33.10:8089/repository/spring-central/org/springframework/integration/spring-integration-bom/5.4.3/spring-integration-bom-5.4.3.pom
Downloading from Maven Repomaven-spring-public: http://192.168.33.10:8089/repository/spring-central/org/springframework/security/spring-security-bom/5.4.2/spring-security-bom-5.4.2.pom
Downloading from Maven Repomaven-spring-public: http://192.168.33.10:8089/repository/spring-central/org/springframework/session/spring-session-bom/2020.0.1/spring-session-bom-2020.0.1.pom
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Non-resolvable import POM: Could not transfer artifact com.datastax.oss:java-driver-bom:pom:4.9.0 from/to Maven Repo maven-spring-public (http://192.168.33.10:8089/repository/spring-central/): Transfer failed for http://192.168.33.10:8089/repository/spring-central/com/datastax/oss/java-driver-bom/4.9.0/java-driver-bom-4.9.0.pom 503 Service Unavailable @ org.springframework.boot:spring-boot-dependencies:2.4.2, C:\Users\hyunaoh\.m2\repository\org\springframework\boot\spring-boot-dependencies\2.4.2\spring-boot-dependencies-2.4.2.pom, line 2577, column 19
[ERROR] Non-resolvable import POM: Could not transfer artifact io.dropwizard.metrics:metrics-bom:pom:4.1.17 from/to Maven Repo maven-spring-public (http://192.168.33.10:8089/repository/spring-central/): Transfer failed for http://192.168.33.10:8089/repository/spring-central/io/dropwizard/metrics/metrics-bom/4.1.17/metrics-bom-4.1.17.pom 502 Bad Gateway @ org.springframework.boot:spring-boot-dependencies:2.4.2, C:\Users\hyunaoh\.m2\repository\org\springframework\boot\spring-boot-dependencies\2.4.2\spring-boot-dependencies-2.4.2.pom, line 2584, column 19
[ERROR] Non-resolvable import POM: Could not transfer artifact org.codehaus.groovy:groovy-bom:pom:2.5.14 from/to Maven Repomaven-spring-public (http://192.168.33.10:8089/repository/spring-central/): Transfer failed for http://192.168.33.10:8089/repository/spring-central/org/codehaus/groovy/groovy-bom/2.5.14/groovy-bom-2.5.14.pom 502 Bad Gateway @ org.springframework.boot:spring-boot-dependencies:2.4.2, C:\Users\hyunaoh\.m2\repository\org\springframework\boot\spring-boot-dependencies\2.4.2\spring-boot-dependencies-2.4.2.pom, line 2591, column 19

...생략

...

maven deploy 커맨드로 Spring Boot의 빌드한 JAR 파일을 Nexus에 배포

  • Repositories에 등록되어 있는 maven-snapshots repository를 이용하여 배포할 계획입니다.
  • 정리하자면, maven-public repository에서 pom.xml에 있는 파일들을 미러링→ 해당 jar 파일들을 다운로드 → maven-snapshots repository에 배포한다는 계획입니다.
  • 다음은 settings.xml에 deploy 설정을 추가한 내용입니다.


코드 블럭
titlesettings.xml
linenumberstrue
<?xml version="1.0" encoding="UTF-8"?>
<settings   xmlns="http://maven.apache.org/SETTINGS/1.0.0"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
			
	<mirrors>
		<mirror>
		  <id>maven-public</id>
		  <name>maven-public</name>
		  <url>http://192.168.33.10:8089/repository/maven-public/</url>
		  <mirrorOf>central</mirrorOf>
		</mirror>
	</mirrors>

	<!-- pom.xml의 snapshotRepository id와 Nexus username 및 password를 입력해줍니다. -->
	<servers>
	   <server>
		  <id>nexus-snapshots</id>
		  <username>admin</username>
		  <password>****</password>
	   </server>
	</servers>

</settings>
  • 다음은 pom.xml 파일입니다.
코드 블럭
titlepom.xml
... 생략

	<build>
        <plugins>
            ... 생략
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>${maven-deploy-plugin.version}</version>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.sonatype.plugins</groupId>
                <artifactId>nexus-staging-maven-plugin</artifactId>
                <version>1.5.1</version>
                <executions>
                    <execution>
                        <id>default-deploy</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>deploy</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <serverId>nexus</serverId>
                    <nexusUrl>http://192.168.33.10:8089/repository/maven-snapshots/</nexusUrl>
                    <skipStaging>true</skipStaging>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <distributionManagement>
        <snapshotRepository>
            <id>nexus-snapshots</id>
            <url>http://192.168.33.10:8089/repository/maven-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>

... 생략
  • 설정이 완료 되었다면, maven clean deploy -Dmaven.test.skip=true 명령어를 통해 maven을 실행시킵니다. (저는 Windows에 maven설치가 안되어 있어 spring boot 프로젝트의 mvnw 파일을 통해 mvn 명령어로 실행하였습니다.)


코드 블럭
titlemaven deploy
linenumberstrue
>mvn clean deploy -Dmaven.test.skip=true -e
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------------< com.example:demo >--------------------------
[INFO] Building demo 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ demo ---
[INFO] Deleting C:\Users\hyunaoh\git\nexus-maven-demo\target
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ demo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ demo ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\Users\hyunaoh\git\nexus-maven-demo\target\classes
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) @ demo ---
[INFO] Not copying test resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ demo ---
[INFO] Not compiling test sources
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ demo ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:3.2.0:jar (default-jar) @ demo ---
[INFO] Building jar: C:\Users\hyunaoh\git\nexus-maven-demo\target\demo-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.4.2:repackage (repackage) @ demo ---
[INFO] Replacing main artifact with repackaged archive
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ demo ---
[INFO] Installing C:\Users\hyunaoh\git\nexus-maven-demo\target\demo-0.0.1-SNAPSHOT.jar to C:\Users\hyunaoh\.m2\repository\com\example\demo\0.0.1-SNAPSHOT\demo-0.0.1-SNAPSHOT.jar
[INFO] Installing C:\Users\hyunaoh\git\nexus-maven-demo\pom.xml to C:\Users\hyunaoh\.m2\repository\com\example\demo\0.0.1-SNAPSHOT\demo-0.0.1-SNAPSHOT.pom
[INFO]
[INFO] --- maven-deploy-plugin:2.8.2:deploy (default-deploy) @ demo ---
[INFO] Skipping artifact deployment
[INFO]
[INFO] --- nexus-staging-maven-plugin:1.5.1:deploy (default-deploy) @ demo ---
[INFO] Performing deferred deploys (gathering into "C:\Users\hyunaoh\git\nexus-maven-demo\target\nexus-staging\deferred")...
[INFO] Installing C:\Users\hyunaoh\git\nexus-maven-demo\target\demo-0.0.1-SNAPSHOT.jar to C:\Users\hyunaoh\git\nexus-maven-demo\target\nexus-staging\deferred\com\example\demo\0.0.1-SNAPSHOT\demo-0.0.1-SNAPSHOT.jar
[INFO] Installing C:\Users\hyunaoh\git\nexus-maven-demo\pom.xml to C:\Users\hyunaoh\git\nexus-maven-demo\target\nexus-staging\deferred\com\example\demo\0.0.1-SNAPSHOT\demo-0.0.1-SNAPSHOT.pom
[INFO] Deploying remotely...
[INFO] Bulk deploying locally gathered artifacts from directory:
[INFO]  * Bulk deploying locally gathered snapshot artifacts to URL http://192.168.33.10:8089/repository/maven-snapshots/
Downloading from nexus-snapshots: http://192.168.33.10:8089/repository/maven-snapshots/com/example/demo/0.0.1-SNAPSHOT/maven-metadata.xml
Uploading to nexus-snapshots: http://192.168.33.10:8089/repository/maven-snapshots/com/example/demo/0.0.1-SNAPSHOT/demo-0.0.1-20210130.101513-1.jar
Uploaded to nexus-snapshots: http://192.168.33.10:8089/repository/maven-snapshots/com/example/demo/0.0.1-SNAPSHOT/demo-0.0.1-20210130.101513-1.jar (8.5 MB at 872 kB/s)
Uploading to nexus-snapshots: http://192.168.33.10:8089/repository/maven-snapshots/com/example/demo/0.0.1-SNAPSHOT/demo-0.0.1-20210130.101513-1.pom
Uploaded to nexus-snapshots: http://192.168.33.10:8089/repository/maven-snapshots/com/example/demo/0.0.1-SNAPSHOT/demo-0.0.1-20210130.101513-1.pom (2.9 kB at 315 B/s)
Downloading from nexus-snapshots: http://192.168.33.10:8089/repository/maven-snapshots/com/example/demo/maven-metadata.xml
Uploading to nexus-snapshots: http://192.168.33.10:8089/repository/maven-snapshots/com/example/demo/0.0.1-SNAPSHOT/maven-metadata.xml
Uploaded to nexus-snapshots: http://192.168.33.10:8089/repository/maven-snapshots/com/example/demo/0.0.1-SNAPSHOT/maven-metadata.xml (765 B at 84 B/s)
Uploading to nexus-snapshots: http://192.168.33.10:8089/repository/maven-snapshots/com/example/demo/maven-metadata.xml
Uploaded to nexus-snapshots: http://192.168.33.10:8089/repository/maven-snapshots/com/example/demo/maven-metadata.xml (275 B at 30 B/s)
[INFO]  * Bulk deploy of locally gathered snapshot artifacts finished.
[INFO] Remote deploy finished with success.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  41.025 s
[INFO] Finished at: 2021-01-30T19:15:50+09:00
[INFO] ------------------------------------------------------------------------


  •  배포 완료 후 Nexus Repository 화면입니다.

Image Added

작성중...