• Home
  • About
    • Junseok photo

      Junseok

      개발자 블로그

    • Learn More
    • Facebook
    • Instagram
    • Github
  • Posts
    • All Posts
    • All Tags
  • Java
    • java-basic
    • java-solid
    • java-pattern
    • java-logging
  • Javascript
  • Angular
  • spring
    • spring-framework
    • spring-boot
    • spring-test
  • server
    • jeus
    • webtob
    • tomcat
  • test
    • junit
    • assertj
    • hamcrest
    • dbunit
    • spring
  • docker
  • unix
  • maven
  • db
  • network
  • eclipse
  • intellij
  • microservices
  • etc

Maven 저장소 관련 설정

17 Apr 2019

Reading time ~1 minute

  • settings.xml 경로
  • %MAVEN_HOME%\conf\settings.xml

  • settings.xml 임의 경로 설정(eclipse)
  • windows > Prefrences > Maven > User Settings

settings.xml

<?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">

	<localRepository>C:/dev/maven/repository</localRepository>

	<interactiveMode>true</interactiveMode>

	<offline>false</offline>

	<pluginGroups>
	</pluginGroups>

	<proxies>

	</proxies>

	<servers>

		<server>
			<id>releases</id>
			<username>ojs</username>
			<password>ojs123</password>
		</server>

		<server>
			<id>snapshots</id>
			<username>ojs</username>
			<password>ojs123</password>
		</server>

		<server>
			<id>thirdparty</id>
			<username>ojs</username>
			<password>ojs123</password>
		</server>

	</servers>


	<mirrors>
	</mirrors>

	<profiles>

		<profile>
			<id>spring</id>

			<activation>
				<jdk>1.7</jdk>
			</activation>

			<repositories>

			</repositories>

			<pluginRepositories>
				<pluginRepository>
					<id>releases</id>
					<url>http://저장소ip/nexus/content/repositories/releases/</url>
					<releases>
						<enabled>true</enabled>
					</releases>
					<snapshots>
						<enabled>false</enabled>
					</snapshots>
				</pluginRepository>
				<pluginRepository>
					<id>snapshots</id>
					<url>http://저장소ip/nexus/content/repositories/snapshots/</url>
					<releases>
						<enabled>false</enabled>
					</releases>
					<snapshots>
						<enabled>true</enabled>
					</snapshots>
				</pluginRepository>
			</pluginRepositories>
		</profile>

	</profiles>

	<activeProfiles>
		<activeProfile>spring</activeProfile>
	</activeProfiles>
</settings>

<distributionManagement> 태그

deploy 하려는 저장소를 설정한다.

pom.xml

<project>
  <distributionManagement>
      <repository>
          <id>releases</id>
          <url>https://저장소ip/content/repositories/releases</url>
      </repository>
      <snapshotRepository>
          <id>snapshots</id>
          <url>https://저장소ip/content/repositories/snapshots</url>
      </snapshotRepository>
  </distributionManagement>
<project>

pom.xml 에 deploy 저장소를 설정했다면 실제 deploy 되는 저장소의 계정 정보를 settings.xml 에 기술한다.

settings.xml

<settings>
  <servers>
    <server>
      <id>releases</id>
      <username>ojs</username>
      <password>ojs123</password>
    </server>
    <server>
      <id>snapshots</id>
      <username>ojs</username>
      <password>ojs123</password>
    </server>
  </servers>
</settings>

<distributionManagement> 의 id 와 <server> 의 id 는 일치해야 한다.

maven goal 에는 install 과 deploy 라는 goal 명령어를 사용할 수 있다.

install 은 localRepository 에 artifact 가 올라간다.
deploy 명령을 사용해야 위에 설정된 deploy 저장소 에 artifact 가 올라간다.

원격 repository 사용하기

  • maven의 기본 중앙저장소 https://repo.maven.apache.org/maven2/
  • 기본으로 제공하는 저장소가 아닌 다른 저장소를 사용하는 방법.

pom.xml

<repositories>

  <repository>
    <id>public</id>
    <name>Public Repositories</name>
    <url>http://저장소ip/nexus/content/groups/public/</url>
  </repository>

  <repository>
    <id>central</id>
    <url>http://저장소ip/nexus/content/repositories/central/</url>
    <releases>
      <enabled>true</enabled>
    </releases>
  </repository>

  <repository>
    <id>egovframe</id>
    <url>http://저장소ip/nexus/content/repositories/egovframe/</url>
    <releases>
      <enabled>true</enabled>
    </releases>
    <snapshots>
      <enabled>false</enabled>
    </snapshots>
  </repository>

</repositories>

<pluginRepositories> 태그

pom.xml 과 settings.xml 에 설정할 수 있다.

pom.xml 에 설정하게 되면 해당 프로젝트에 해당하고 settings.xml 에 설정하게 되면 모든 프로젝트에 해당한다.

settings.xml

<profile>
  <pluginRepositories>
    <pluginRepository>
      <id>releases</id>
      <url>http://저장소ip/nexus/content/repositories/releases/</url>
      <releases>
        <enabled>true</enabled>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </pluginRepository>
    <pluginRepository>
      <id>snapshots</id>
      <url>http://저장소ip/nexus/content/repositories/snapshots/</url>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </pluginRepository>
  </pluginRepositories>
</profile>


maven Share Tweet +1