创建原型

1 创建原型

    使用maven官方提供的原型(maven-archetype-archetype)来创建自己的原型(test-archetype)

    cmd进入要创建原型的目录,输入

    mvn archetype:create -DgroupId=com.sdecp -DartifactId=test-archetype -DarchetypeArtifactId=maven-archetype-archetype

 

注意:maven-archetype-archetype 不可更改

生成原型将同时生成一个archetype.xml文件,内容如下

<archetype>
  <id>test-archetype</id>
  <sources>
    <source>src/main/java/App.java</source>
  </sources>
  <testSources>
    <source>src/test/java/AppTest.java</source>
  </testSources>
</archetype>

 

2 生成eclipse项目

  进入到test-archetype目录下。运行 mvn eclipse:eclipse 可以生成eclipse项目

 

3  导入到eclipse

    将生成的原型eclipse项目导入到eclipse中,可以查看现有的目录结构

                

 
      

  4 编写SCA 的maven模型

     现在需要增加一个 App.composite  构件文件,位置在src/main/resources/archetype-resources/src/main/resources

<?xml version="1.0" encoding="UTF-8"?>
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
		   targetNamespace="http://test-archetype"
		   name="App">
    <component name="AppComponent">
        <implementation.java class="${package}.App"/>
    </component>

</composite>

 

5 修改原型描述文件 archetype.xml

    增加对App.composite的配置

 

<archetype>
  <id>test-archetype</id>
  <sources>
    <source>src/main/java/App.java</source>
  </sources>
  <sources>
     <source>src/main/resources/App.compsite</source>
  </sources>
  <testSources>
    <source>src/test/java/AppTest.java</source>
  </testSources>
</archetype>

 

6 修改项目对象文件 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>
  <packaging>jar</packaging>
  <version>${version}</version>
  <name>${artifactId}</name>
   
  <repositories>
     <repository>
        <id>apache.incubator</id>
        <url>http://people.apache.org/repo/m2-incubating-repository</url>
     </repository>
  </repositories>

  <dependencies>
  
      <dependency>
          <groupId>org.apache.tuscany.sca</groupId>
          <artifactId>tuscany-host-webapp</artifactId>
          <version>1.6</version>
      </dependency>
  
      <dependency>
          <groupId>org.apache.tuscany.sca</groupId>
          <artifactId>tuscany-binding-ws-axis2</artifactId>
          <version>1.6</version>
      </dependency>   

      <dependency>
          <groupId>org.apache.tuscany.sca</groupId>
          <artifactId>tuscany-implementation-java-runtime</artifactId>
          <version>1.6</version>
          <scope>runtime</scope>
      </dependency>

      <!-- exclude stax 1.0.1 as we're also pulling in javax\xml\stream\stax-api\1.0-2 -->
      <dependency>
          <groupId>stax</groupId>
          <artifactId>stax-api</artifactId>
          <version>1.0.1</version>
          <scope>provided</scope>
      </dependency>

      <!-- marking dependency as provided to exclude from war file -->
      <dependency>
          <groupId>javax.servlet</groupId>
          <artifactId>servlet-api</artifactId>
          <version>2.3</version>
          <scope>provided</scope>
      </dependency>

      <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>4.5</version>
          <scope>test</scope>
      </dependency>

  </dependencies>

  <build>
  	<pluginManagement>
  		<!-- compiler plugin configuration -->
  		 <plugins>
          <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-compliler-plugin</artifactId>
              <version>2.0.11</version>
              <configuration>
                <source>1.5</source>
                <target>1.5</target>
              </configuration>
          </plugin>
         </plugins> 
  	</pluginManagement>
           
  </build>
</project>

 

 

 


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值