精华内容
下载资源
问答
  • 问题描述: 使用Eclipse自带的Maven插件创建Web...Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webapp:RELEASE from any of the configured repositories. Could not resolve artifa

    问题描述:

            使用Eclipse自带的Maven插件创建Web项目时报错:

    Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webapp:RELEASE from any of the configured repositories.
    Could not resolve artifact org.apache.maven.archetypes:maven-archetype-webapp:pom:RELEASE
    Failed to resolve version for org.apache.maven.archetypes:maven-archetype-webapp:pom:RELEASE: Could not find metadata org.apache.maven.archetypes:maven-archetype-webapp/maven-metadata.xml in local (C:\Users\liujunguang\.m2\repository)
    Failed to resolve version for org.apache.maven.archetypes:maven-archetype-webapp:pom:RELEASE: Could not find metadata org.apache.maven.archetypes:maven-archetype-webapp/maven-metadata.xml in local (C:\Users\liujunguang\.m2\repository)

    错误如图:

     

    解决方案:

    1. 在Eclipse Maven配置中添加新的Catalog配置:

     
    2. 也可以下载到本地,然后再添加,这样比较快(推荐)
     
         如图:

     

     

    接下来在使用刚添加的catalog创建web工程

          

        这个时候就可以看到Eclipse联网下载了:

         
    这个时候看一下是不是创建成功了

     

    如果还是不能创建或者问题没有解决可以安装下面的方法:

    1.删除maven已经下载的文件路径:.m2\repository\org\apache\maven

    删除之后再试下,这时候如果看到有进度,只需要耐心等待就行了

     

    2.Maven下载jar慢可以使用国内阿里镜像

    具体配置文件(settings.xml)如下,放在.m2文件夹下,.m2一般位于用户目录下

    打开 maven 的配置文件( windows 机器一般在 maven 安装目录的 conf/settings.xml ),在<mirrors></mirrors>标签中添加 mirror 子节点:

    <mirror>
      <id>aliyunmaven</id>
      <mirrorOf>*</mirrorOf>
      <name>阿里云公共仓库</name>
      <url>https://maven.aliyun.com/repository/public</url>
    </mirror>
    如果想使用其它代理仓库,可在<repositories></repositories>节点中加入对应的仓库使用地址。以使用 spring 代理仓为例:
    <repository>
      <id>spring</id>
      <url>https://maven.aliyun.com/repository/spring</url>
      <releases>
        <enabled>true</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>

    参考文档:https://maven.aliyun.com/mvn/guide

    展开全文
  • archetype

    2014-12-28 21:15:28
    [url=http://maven.apache.org/archetype/maven-archetype-plugin/]网址[/url] 该插件为maven原型插件,该插件平台上存储了多种常见的项目配置方式,比如web应用,jse应用等。可以通过该原型插件快件创建项目。 ...
    [url=http://maven.apache.org/archetype/maven-archetype-plugin/]网址[/url]
    该插件为maven原型插件,该插件平台上存储了多种常见的项目配置方式,比如web应用,jse应用等。可以通过该原型插件快件创建项目。

    [img]http://maven.apache.org/archetype/maven-archetype-plugin/images/archetype-overview.png[/img]

    mvn archetype:generate
    运行该命令后,会生产一个默认的原型项目配置
    或者
    mvn archetype:generate -DgroupId=cgodo -DartifactId=cgodo_lang

    #web项目
    mvn archetype:create -DgroupId=cgodo-web -DartifactId=web -DpackageName
    =com.cgodo.web -DarchetypeArtifactId=maven-archetype-webapp

    貌似generate和create目标功能类似。
    展开全文
  • Maven自身提供了许多Archetype来方便用户创建Project,但是每个团队都可能会有一些常用的文件或配置,为了避免在创建project时重复的拷贝和修改,我们通过自定义Archetype来规范显得还蛮有必要,下面简单介绍下使用...

    Maven自身提供了许多Archetype来方便用户创建Project,但是每个团队都可能会有一些常用的文件或配置,为了避免在创建project时重复的拷贝和修改,我们通过自定义Archetype来规范显得还蛮有必要,下面简单介绍下使用maven-archetype-archetype来构建自己的Archetype的过程。

    1,创建自己的Archetype项目

    模板

    mvn archetype:generate   \
      -DarchetypeGroupId=<archetype-groupId>  \
      -DarchetypeArtifactId=<archetype-artifactId> \
      -DarchetypeVersion=<archetype-version>   \
      -DgroupId=<my.groupid> \
      -DartifactId=<my-artifactId>

    例如:

    mvn archetype:generate \
      -DgroupId=com.ultrapower.maven.archetypes \
      -DartifactId=springboot-maven-archetype  \
      -DarchetypeArtifactId=maven-archetype-archetype   \
      -DinteractiveMode=false \
      -X

    自定义Maven Archetype之 maven-archetype-archetype

    1) springboot-maven-archetype下的pom.xml和一般的maven项目一样用于定义archetype项目的坐标等信息
    2) springboot-maven-archetype/src/main/resources/archetype-resources下的所有内容定义了待生成项目的所有文件(原型文件)
    3) springboot-maven-archetype/ src/main/resources/META-INF/maven/archetype.xml中定义骨架的描述符(元数据),这个文件列出了包含在archetype中的所有文件并将这些文件分类。

    注:springboot-maven-archetype/pom.xml如下

    <project xmlns="http://maven.apache.org/POM/4.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.ultrapower.maven.archetypes</groupId>
        <artifactId>springboot-maven-archetype</artifactId>
        <version>1.0-SNAPSHOT</version>
        <name>Archetype - springboot-maven-archetype</name>
        <url>http://maven.apache.org</url>
    </project>
    

    2,修改archetype-resources下的pom.xml,添加需要的配置

    如:

    <project xmlns="http://maven.apache.org/POM/4.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
        http://maven.apache.org/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>${groupId}</groupId>
        <artifactId>${artifactId}</artifactId>
        <version>${version}</version>
        <packaging>jar</packaging>
        <name>${artifactId}</name>
        <url>http://www.myorganization.org</url>
    
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.0.0.RELEASE</version>
            <relativePath /> <!-- lookup parent from repository -->
        </parent>
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
            <java.version>1.8</java.version>
        </properties>
    
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
            <dependency>
                <groupId>io.springfox</groupId>
                <artifactId>springfox-swagger2</artifactId>
                <version>2.8.0</version>
            </dependency>
            <dependency>
                <groupId>io.springfox</groupId>
                <artifactId>springfox-swagger-ui</artifactId>
                <version>2.8.0</version>
            </dependency>
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-lang3</artifactId>
            </dependency>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>3.8.1</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </project>

    3,添加需要的文件

    例如:
    自定义Maven Archetype之 maven-archetype-archetype

    如Application.java

    package ${package};
    
    import org.springframework.boot.Banner;
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
    import org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration;
    import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
    import org.springframework.boot.web.servlet.FilterRegistrationBean;
    import org.springframework.boot.web.servlet.ServletComponentScan;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.ComponentScan;
    
    @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class,
            JmsAutoConfiguration.class })
    @ServletComponentScan
    @ComponentScan(basePackages = { "${package}" })
    public class Application {
    
        public static void main(String[] args) {
            SpringApplication app = new SpringApplication(Application.class);
            app.setBannerMode(Banner.Mode.OFF);
            app.run(args);
        }
    }

    如CorsConfig.java

    package ${package}.config.beanconfig;
    
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.web.cors.CorsConfiguration;
    import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
    import org.springframework.web.filter.CorsFilter;
    
    @Configuration
    public class CorsConfig {
        private CorsConfiguration buildConfig() {
            CorsConfiguration corsConfiguration = new CorsConfiguration();
            // 1 设置访问源地址
            corsConfiguration.addAllowedOrigin("*");
            // 2 设置访问源请求头
            corsConfiguration.addAllowedHeader("*");
            // 3 设置访问源请求方法
            corsConfiguration.addAllowedMethod("*");
            return corsConfiguration;
        }
    
        @Bean
        public CorsFilter corsFilter() {
            UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
            // 4 对接口配置跨域设置
            source.registerCorsConfiguration("/**", buildConfig());
            return new CorsFilter(source);
        }
    }
    

    4,修改archetype.xml文件

    如:

    <archetype xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype/1.0.0 http://maven.apache.org/xsd/archetype-1.0.0.xsd">
    
        <id>springboot-maven-archetype</id>
        <sources>
            <source encoding="UTF-8">src/main/java/Application.java</source>
            <source encoding="UTF-8">src/main/java/config/beanconfig/MvcConfig.java</source>
            <source encoding="UTF-8">src/main/java/config/beanconfig/CorsConfig.java</source>
            <source encoding="UTF-8">src/main/java/config/beanconfig/RestTemplateConfig.java</source>
            <source encoding="UTF-8">src/main/java/config/beanconfig/Swagger2Config.java</source>
            <source encoding="UTF-8">src/main/java/config/condition/Swagger2Condition.java</source>
        </sources>
        <resources>
            <resource encoding="UTF-8">src/main/resources/application.yml</resource>
            <resource encoding="UTF-8">src/main/resources/application-dev.yml</resource>
            <resource encoding="UTF-8">src/main/resources/application-prod.yml</resource>
            <resource encoding="UTF-8">boot/control.sh</resource>
            <resource encoding="UTF-8">boot/control.bat</resource>
        </resources>
        <testSources>
            <source>src/test/java/AppTest.java</source>
        </testSources>
    </archetype>

    上面是将每个文件都列出来了,还可以使用通配符的方式来简化配置,例如:

    <archetype xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype/1.0.0 http://maven.apache.org/xsd/archetype-1.0.0.xsd">
    
        <id>springboot-maven-archetype</id>
        <sources>
            <source encoding="UTF-8">src/main/java/**/*.*</source>
        </sources>
        <resources>
            <resource encoding="UTF-8">**/*.*</resource>
        </resources>
        <testSources>
            <source>src/test/java/AppTest.java</source>
        </testSources>
    </archetype>

    5,安装archetype

    mvn install

    6,使用自定义的archetype创建项目

    mvn archetype:generate  -DarchetypeGroupId=com.ultrapower.maven.archetypes  -DarchetypeArtifactId=springboot-maven-archetype  -DarchetypeVersion=1.0-SNAPSHOT -DgroupId=com.ultrapower.ioss -DartifactId=springboot-archetype-test -X

    注意: 我们可以将archetype.xml换成“archetype-metadata.xml”,以下的内容可以达到同样的效果,但还是推荐archetype.xml

    archetype-metadata.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <archetype-descriptor name="beast-archetype"
        xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="
                http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0
                http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd">
    
        <requiredProperties>
            <requiredProperty key="package" />
        </requiredProperties>
    
        <fileSets>
            <fileSet filtered="true" packaged="true" encoding="UTF-8">
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.java</include>
                </includes>
            </fileSet>
            <fileSet filtered="true" encoding="UTF-8">
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.*</include>
                </includes>
            </fileSet>
            <fileSet filtered="true" encoding="UTF-8">
                <directory>boot</directory>
                <includes>
                    <include>**/*.*</include>
                </includes>
            </fileSet>
            <fileSet filtered="true" packaged="true" encoding="UTF-8">
                <directory>src/test/java</directory>
                <includes>
                    <include>**/*.java</include>
                </includes>
            </fileSet>
            <fileSet encoding="UTF-8">
                <directory>src/test/resources</directory>
                <includes>
                    <include>**/*.*</include>
                </includes>
            </fileSet>
        </fileSets>
    </archetype-descriptor>

    转载于:https://blog.51cto.com/dengshuangfu/2344615

    展开全文
  • maven archetype

    2018-02-28 15:14:17
    概括图很形象,来自https://maven.apache.org/archetype/maven-archetype-plugin/index.html 从工程创建原型 mvn archetype:create-from-project 如果需要参数定制化 ...

    概括图很形象,来自https://maven.apache.org/archetype/maven-archetype-plugin/index.html

    这里写图片描述

    1. 从工程创建原型
      mvn archetype:create-from-project

      如果需要参数定制化
      https://maven.apache.org/archetype/maven-archetype-plugin/examples/create-with-property-file.html

    2. 进入/target/generated-sources/archetype目录

          find ./ -name target |xargs rm -rf 删除自动生成的target
          find ./ -name \.\*|grep src|xargs rm -rf 删除.开头的文件
          mvn clean install/deploy

      安装archetype到本地仓库
      archetype安装的地址是在maven安装目录下面的conf/settings.xml文件中指定的(字节)。

      默认会在 ~/.m2 目录下面生成一个archetype-catalog.xml文件(和默认的settings.xml在同一个目录

    3. Eclipse创建maven项目过程中,选择的“Default Local”指向的地址就是 ~/.m2,
      所以文件archetype-catalog.xml会被eclipse自动读取,使用eclipse创建maven项目的时候可以在”Default Local”一项中找到刚才自定义archetype名字。

      当eclipse的maven设置中,User Settings选择的settings.xml指向的本地仓库地址和maven安装目录下的那个settings.xml中指向路径一样的时候,eclipse才能读取得到刚才安装的自定义的archetype的源文件,这样eclipse才能复制源文件并创建项目。

    4. 卸载安装的archetype,将~/.m2目录下面的archetype-catalog.xml文件中对应的字节段删掉,并且把本地仓库中相应groupId和artifactId下面的文件删掉

    5. 安装到本地仓库中的archetype只可以被自己使用,如果想要共享,那么必须deploy到内部maven仓库中

    6. 如果想要生成项目,列出所有的archetype, mvn archetype:generate ;只列出本地archetype,mvn archetype:generate -DarchetypeCatalog=local
      筛选archetype,后面必须加“:”,可以只显示某个groupId下面的archetype

      mvn archetype:generate -Dfilter=com.glowd.arch:
    7. 如果使用的是maven-archetype-plugin 2.4,可以直接在命令行生成archetype工程,不需要进入交互模式,但是最新版的maven已经不支持了,基于安全考虑

      mvn org.apache.maven.plugins:maven-archetype-plugin:2.4:generate -DarchetypeCatalog=http://nexus.glowd.com:1998/nexus/content/repositories/releases/com/glowd/sample/sample-archetype/0.0.1/sample-archetype-0.0.1.pom  
    8. mvn archetype:crawl

      扫描整个~/.m2/repository/,将扫描到的所有的archetype进行排序更新,在我们执行mvn archetype:generate -DarchetypeCatalog=local时能够看到所有整理过后的扫描项,
      扫描的内容在~/.m2/repository/archetype-catalog.xml中

    9. Testing

      The user can provide archetype test projects by placing them in src/it/projects folder of their project. Upon creating archetype from the existing project all the test projects will be executed to verify the archetype created by this project is good. Read more about testing maven archetype.
      具体参考https://maven.apache.org/archetype/maven-archetype-plugin/integration-test-mojo.html

    10. Configuration
      The create-from-project goal enable the user to provide some sensible configuration using the system properties or a property file.
      The system properties permits the user to define the groupId, artifactId, version of the created archetype. They also permits to override the resolved package and to create a partial archetype.
      When used, the property file takes precedence over the system properties. It is also the only way to define additional properties in the archetype.

      具体参考https://maven.apache.org/archetype/maven-archetype-plugin/examples/create-with-property-file.html

    11. Post-generation script
      If the user wants to customize the generated project even further, a groovy script named archetype-post-generate.groovy can be added in src/main/resources/META-INF/. This script will end up in the generated archetype’s META-INF folder and will be executed upon creating a project from this archetype. This groovy script has access to the ArchetypeGenerationRequest object, as well as all the System.getProperties() and all the archetype generation properties the user has specified.

    展开全文
  • Maven archetype

    2020-12-28 22:35:44
    <div><p>Archetype maven project</p><p>该提问来源于开源项目:yegor256/eo</p></div>
  • Maven之自定义archetype生成项目骨架(一)

    万次阅读 热门讨论 2015-07-15 16:40:45
    摘要:使用过Maven的人都知道maven中有许多功能都是通过插件来提供的,今天我们来说一下其中的一个插件:maven-archetype-plugin ,通过该插件可以自定义符合我们自己需求的archetype。 一:什么是Archetype 总之...
  • Maven Archetype

    2020-04-20 12:39:36
    What is Archetype? In short, Archetype is a Maven project templating toolkit. An archetype is defined as an original pattern or model from which all other things of the same kind are made. The names f...
  • archetype.zip

    2019-10-11 11:48:52
    archetype-catalog文件,配置之后maven加载快
  • <div><p>Help readability of <code>ArchetypeBuilder.Archetype</code> by promoting it top level class.</p><p>该提问来源于开源项目:junkdog/artemis-odb</p></div>
  • [ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.0.1:generate (default-cli) on project standalone-pom: The desired archetype does not exist (pl.codeleak:spring-mvc-...
  • archetype说明

    2020-05-27 11:47:33
    新建Maven project项目时,需要选择archetype。 那么,什么是archetypearchetype的意思就是模板原型的意思,原型是一个Maven项目模板工具包。一个原型被定义为从其中相同类型的所有其它事情是由一个原始图案或...
  • archetype-catalog

    2018-09-28 15:48:20
    新建maven项目时报Could not resolve archetype org.apache.maven.archetypes
  • <div><h3>Getting below Error while creating an archetype [WARNING] Archetype not found in any catalog. Falling back to central repository. [WARNING] Add a repository with id 'archetype' in ...
  • archetype-catalog.xml

    2021-05-02 22:32:06
    IDEA新建Maven项目时勾选 Create from archetype会用到,archetype-catalog.xml 该文档:2021年5月2日 获取。官方页面:https://repo1.maven.org/maven2/archetype-catalog.xml
  • Create an archetype

    2020-12-25 17:29:50
    <div><p>Be able to create a project using archetype. <p>It would be handy to create an archetype from one of the samples. </p><p>该提问来源于开源项目:ArcBees/GWTP</p></div>
  • maven archetype制作

    2021-03-13 17:58:30
    maven archetype制作 什么是maven archetype? maven-archetype-archetype is an archetype which generates a sample archetype 上述是官网的描述,可以看出archetype是用于生成原型的项目。 例如我们在用idea生成...
  • Archetype原型 也就是说为项目生成一个原型,可以把这个项目发布,其他人就可以直接通过命令构建一个原型项目了。其实我一开始也是不知道maven还有这个功能的,但是在使用的springside的构建项目时候,发现这个功能...
  • Automatic archetype creation

    2020-12-27 15:46:39
    <div><p>This will allow doing builds/releases without the manual step to create the archetype. By doing from the root folder: - mvn install or - mvn deploy <p>The archetype will be generated and ...
  • maven-logo-black-on-white.png说说如何使用 Maven Archetype 来创建项目模版,从项目模块结构上,统一开发规范。Maven Archetype了解 maven 的同学,应该使用过如下命令来构建一个空的 maven 项目骨架mvn archetype:...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 10,206
精华内容 4,082
热门标签
关键字:

archetype