

macOS で Mavenを勉強中です。

### 事前に行った環境設定

Homebrew で maven をインストールし、PATHを設定しました。

[code]

    export M2_HOME=/usr/local/Cellar/maven/3.6.3/libexec
    export PATH=$M2_HOME/bin:$PATH
    
[/code]

JDKもインストールしPATHを通しました。

[code]

    export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-14.0.1.jdk/Contents/Home
    export PATH=$JAVA_HOME/bin:$PATH
    
[/code]

[code]

    @MacBook-Pro Desktop % mvn -version          
    Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
    Maven home: /usr/local/Cellar/maven/3.6.3_1/libexec
    Java version: 13.0.2, vendor: N/A, runtime: /usr/local/Cellar/openjdk/13.0.2+8_2/libexec/openjdk.jdk/Contents/Home
    Default locale: ja_JP, platform encoding: UTF-8
    OS name: "mac os x", version: "10.15.5", arch: "x86_64", family: "mac"
    
[/code]

### 問題点

`mvn archetype:generate` コマンドでプロジェクトを作成しようとしましたが、下記のようなエラーでプロジェクトが生成できません。

その他の原因があると思うのですが手詰まりのためご教授いただきたいです。

[code]

    ~/Desktop $ mvn -X archetype:generate
    Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
    Maven home: /usr/local/Cellar/maven/3.6.3_1/libexec
    Java version: 14.0.1, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-14.0.1.jdk/Contents/Home
    Default locale: ja_JP, platform encoding: UTF-8
    OS name: "mac os x", version: "10.15.5", arch: "x86_64", family: "mac"
    [DEBUG] Created new class realm maven.api
    [DEBUG] Importing foreign packages into class realm maven.api
    [DEBUG]   Imported: javax.annotation.* < plexus.core
    [DEBUG]   Imported: javax.annotation.security.* < plexus.core
    [DEBUG]   Imported: javax.enterprise.inject.* < plexus.core
    [DEBUG]   Imported: javax.enterprise.util.* < plexus.core
    [DEBUG]   Imported: javax.inject.* < plexus.core
    [DEBUG]   Imported: org.apache.maven.* < plexus.core
    [DEBUG]   Imported: org.apache.maven.artifact < plexus.core
    [DEBUG]   Imported: org.apache.maven.classrealm < plexus.core
    [DEBUG]   Imported: org.apache.maven.cli < plexus.core
    [DEBUG]   Imported: org.apache.maven.configuration < plexus.core
    [DEBUG]   Imported: org.apache.maven.exception < plexus.core
    [DEBUG]   Imported: org.apache.maven.execution < plexus.core
    [DEBUG]   Imported: org.apache.maven.execution.scope < plexus.core
    [DEBUG]   Imported: org.apache.maven.lifecycle < plexus.core
    [DEBUG]   Imported: org.apache.maven.model < plexus.core
    [DEBUG]   Imported: org.apache.maven.monitor < plexus.core
    [DEBUG]   Imported: org.apache.maven.plugin < plexus.core
    [DEBUG]   Imported: org.apache.maven.profiles < plexus.core
    [DEBUG]   Imported: org.apache.maven.project < plexus.core
    [DEBUG]   Imported: org.apache.maven.reporting < plexus.core
    [DEBUG]   Imported: org.apache.maven.repository < plexus.core
    [DEBUG]   Imported: org.apache.maven.rtinfo < plexus.core
    [DEBUG]   Imported: org.apache.maven.settings < plexus.core
    [DEBUG]   Imported: org.apache.maven.toolchain < plexus.core
    [DEBUG]   Imported: org.apache.maven.usability < plexus.core
    [DEBUG]   Imported: org.apache.maven.wagon.* < plexus.core
    [DEBUG]   Imported: org.apache.maven.wagon.authentication < plexus.core
    [DEBUG]   Imported: org.apache.maven.wagon.authorization < plexus.core
    [DEBUG]   Imported: org.apache.maven.wagon.events < plexus.core
    [DEBUG]   Imported: org.apache.maven.wagon.observers < plexus.core
    [DEBUG]   Imported: org.apache.maven.wagon.proxy < plexus.core
    [DEBUG]   Imported: org.apache.maven.wagon.repository < plexus.core
    [DEBUG]   Imported: org.apache.maven.wagon.resource < plexus.core
    [DEBUG]   Imported: org.codehaus.classworlds < plexus.core
    [DEBUG]   Imported: org.codehaus.plexus.* < plexus.core
    [DEBUG]   Imported: org.codehaus.plexus.classworlds < plexus.core
    [DEBUG]   Imported: org.codehaus.plexus.component < plexus.core
    [DEBUG]   Imported: org.codehaus.plexus.configuration < plexus.core
    [DEBUG]   Imported: org.codehaus.plexus.container < plexus.core
    [DEBUG]   Imported: org.codehaus.plexus.context < plexus.core
    [DEBUG]   Imported: org.codehaus.plexus.lifecycle < plexus.core
    [DEBUG]   Imported: org.codehaus.plexus.logging < plexus.core
    [DEBUG]   Imported: org.codehaus.plexus.personality < plexus.core
    [DEBUG]   Imported: org.codehaus.plexus.util.xml.Xpp3Dom < plexus.core
    [DEBUG]   Imported: org.codehaus.plexus.util.xml.pull.XmlPullParser < plexus.core
    [DEBUG]   Imported: org.codehaus.plexus.util.xml.pull.XmlPullParserException < plexus.core
    [DEBUG]   Imported: org.codehaus.plexus.util.xml.pull.XmlSerializer < plexus.core
    [DEBUG]   Imported: org.eclipse.aether.* < plexus.core
    [DEBUG]   Imported: org.eclipse.aether.artifact < plexus.core
    [DEBUG]   Imported: org.eclipse.aether.collection < plexus.core
    [DEBUG]   Imported: org.eclipse.aether.deployment < plexus.core
    [DEBUG]   Imported: org.eclipse.aether.graph < plexus.core
    [DEBUG]   Imported: org.eclipse.aether.impl < plexus.core
    [DEBUG]   Imported: org.eclipse.aether.installation < plexus.core
    [DEBUG]   Imported: org.eclipse.aether.internal.impl < plexus.core
    [DEBUG]   Imported: org.eclipse.aether.metadata < plexus.core
    [DEBUG]   Imported: org.eclipse.aether.repository < plexus.core
    [DEBUG]   Imported: org.eclipse.aether.resolution < plexus.core
    [DEBUG]   Imported: org.eclipse.aether.spi < plexus.core
    [DEBUG]   Imported: org.eclipse.aether.transfer < plexus.core
    [DEBUG]   Imported: org.eclipse.aether.version < plexus.core
    [DEBUG]   Imported: org.fusesource.jansi.* < plexus.core
    [DEBUG]   Imported: org.slf4j.* < plexus.core
    [DEBUG]   Imported: org.slf4j.event.* < plexus.core
    [DEBUG]   Imported: org.slf4j.helpers.* < plexus.core
    [DEBUG]   Imported: org.slf4j.spi.* < plexus.core
    [DEBUG] Populating class realm maven.api
    [INFO] Error stacktraces are turned on.
    [DEBUG] Message scheme: color
    [DEBUG] Message styles: debug info warning error success failure strong mojo project
    [DEBUG] Reading global settings from /usr/local/Cellar/maven/3.6.3_1/libexec/conf/settings.xml
    [DEBUG] Reading user settings from /Users/taka/.m2/settings.xml
    [ERROR] Error executing Maven.
    org.apache.maven.settings.building.SettingsBuildingException: 1 problem was encountered while building the effective settings
    [FATAL] Non-parseable settings /usr/local/Cellar/maven/3.6.3_1/libexec/conf/settings.xml: end tag name </proxies> must match start tag name <settings> from line 46 (position: TEXT seen ...</proxy>\r\n  \r\n  </proxies>... @106:13)  @ /usr/local/Cellar/maven/3.6.3_1/libexec/conf/settings.xml, line 106, column 13
    
        at org.apache.maven.settings.building.DefaultSettingsBuilder.build (DefaultSettingsBuilder.java:129)
        at org.apache.maven.cli.configuration.SettingsXmlConfigurationProcessor.process (SettingsXmlConfigurationProcessor.java:145)
        at org.apache.maven.cli.MavenCli.configure (MavenCli.java:1166)
        at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:284)
        at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
        at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke (Method.java:564)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    
[/code]


CC BY-SA 4.0
2020-06-21T11:28:20.940
67868
2020-06-25T07:37:05.207
2020-06-22T08:29:07.583
3060
40666
question
maven
mvn archetype:generate コマンドを実行しても、エラーでプロジェクトが作成できない


mavenリポジトリのURL
schemeが「`https`」であるので、プロキシ設定の`<procorol>`の値を`https`にする必要があると思います。

[code]

    <!-- 変更例 -->
    <proxies>
        <!-- proxy
         | Specification for one proxy, to be used in connecting to the network.
         |
         |-->
        <proxy>
          <id>optional</id>
          <active>true</active>
          <protocol>https</protocol> <!-- 注: ここの値を"https"に変更 -->
          <username>proxyuser</username>
          <password>proxypass</password>
          <host>proxy.host.net</host>
          <port>80</port>
          <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
        </proxy>
      </proxies>
    
[/code]


CC BY-SA 4.0
2020-06-21T12:14:05.780
67869
2020-06-21T12:14:05.780
20098
67868
answer


質問に書かれているエラーはXMLの書式誤りを報告しており、おそらく
`/usr/local/Cellar/maven/3.6.3_1/libexec/conf/settings.xml`
のプロキシ設定の部分を編集された後、正しく原状回復できていないのが原因です。

元の状態では次のようになっています

[code]

      <!-- proxies
       | This is a list of proxies which can be used on this machine to connect to the network.
       | Unless otherwise specified (by system property or command-line switch), the first proxy
       | specification in this list marked as active will be used.
       |-->
      <proxies>
        <!-- proxy
         | Specification for one proxy, to be used in connecting to the network.
         |
        <proxy>
          <id>optional</id>
          <active>true</active>
          <protocol>http</protocol>
          <username>proxyuser</username>
          <password>proxypass</password>
          <host>proxy.host.net</host>
          <port>80</port>
          <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
        </proxy>
        -->
      </proxies>
    
[/code]

(`<proxies><!-- ここはコメント --></proxies>`という形です)

ので、このように戻した上で再度

[code]

    mvn -X archetype:generate
    
[/code]

を実行してみてください。


CC BY-SA 4.0
2020-06-22T07:50:42.757
67899
2020-06-25T07:37:05.207
2020-06-25T07:37:05.207
2808
2808
67868
answer