国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

maven第一坑

2019-11-08 03:22:26
字體:
來源:轉載
供稿:網友

maven 命令行指令

mvn clean complie / test / package/ install

cd target

java -jar xxx.jar

剛啃完linux,開始啃maven。按照《maven實戰》的教程,使用命令行進行打包。遇到了一些問題。

首先,最坑爹的一點是,書上并沒有按照maven官方建議的目錄結構進行建立。可能由于還沒有講到目錄結構的原因。

但是按照書中建立目錄結構,導致一直運行不成功。

從mvn clean test命令開始,就有問題,如果直接打包運行,遇到的錯誤為:找不到主類。

maven的目錄結構:

src

  |     main

  |           |          java            ----------com.test.helloworld.HelloWorld.java

  |           |          resources

  |           |          filters

  |       test

  |           |        java             ----------HelloWorldTest.java

  |           |        resource

  |           |        filters

  |       site

  |       assembly

 target

 pom.xml

pom.xml:

         

<?xml version = "1.0" encoding = "UTF-8"?><PRoject xmlns = "http://maven.apache.org/POM/4.0.0"    xmlns:xsi = "http://www.w3.org/2001/XNLSchema-instance"    xsi:schemaLocation = "http://maven.apache.org/POM/4.0/0http://maven.apache.org/maven-v4_0_0.xsd">  <modelVersion>4.0.0</modelVersion>  <groupId>com.test</groupId>  <artifactId>hello-world</artifactId>  <version>1.0-SNAPSHOT</version>  <name>Maven Hello World Project</name>  <dependencies>    <dependency>        <groupId>junit</groupId>            <artifactId>junit</artifactId>        <version>4.7</version>        <scope>test</scope>    </dependency>  </dependencies>  <build>    <plugins>        <plugin>            <groupId>org.apache.maven.plugins</groupId>            <artifactId>maven-compiler-plugin</artifactId>            <configuration>                <source>1.8</source>                <target>1.8</target>            </configuration>        </plugin>        <plugin>            <groupId>org.apache.maven.plugins</groupId>            <artifactId>maven-shade-plugin</artifactId>            <version>1.2.1</version>            <executions>                <execution>                    <phase>package</phase>                    <goals>                        <goal>shade</goal>                    </goals>                    <configuration>                        <transformers>                            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">                            <mainClass>main.java.com.test.helloworld.HelloWorld</mainClass> <!-- 指明主類-->                            </transformer>                        </transformers>                    </configuration>                </execution>            </executions>        </plugin>    </plugins>  </build></project>

HelloWorldTest

package test.java;import main.java.com.test.helloworld.HelloWorld;import junit.framework.Assert;import junit.framework.TestCase;//導入的包名和書中不一致,應該是由于版本的歷史原因?public class HelloWorldTest extends TestCase{    //@Test        注解被注釋掉了,不知道為什么會出錯。    public void testSayHello(){        HelloWorld helloWorld = new HelloWorld();        String result = helloWorld.sayHello();        assertEquals("Hello Maven", result);    }}

HelloWorld:

package main.java.com.test.helloworld;public class HelloWorld{         public String sayHello(){                 return "Hello Maven";           }        public static void main(String[] args){                 System.out.print(new HelloWorld().sayHello());        }}

不在IDE里,打印錯誤是常見錯誤。QAQ


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 日土县| 休宁县| 溧水县| 旅游| 康乐县| 新疆| 麻江县| 新建县| 府谷县| 慈溪市| 泰安市| 和静县| 南乐县| 汉源县| 榆中县| 当雄县| 大姚县| 虞城县| 南平市| 南皮县| 盐津县| 济源市| 双江| 雅安市| 阿荣旗| 繁峙县| 扶风县| 教育| 杨浦区| 库车县| 邳州市| 盖州市| 新郑市| 民勤县| 南宫市| 报价| 贵德县| 治县。| 尚志市| 无极县| 武邑县|