Here eliminating widow maven install, the default installation is successful
maven project directory structure
first create a project maven01
then maven01 which is src
and src which is
then main directory is java
the Test directory is java
and then write the code
package com.imooc. maven.mode1;
public class HelloWorld(){
public String sayHello(){
return "Hello World";
}
}
This saved
and then write a test class
package com.imooc.maven01.model;
import org.junit.;
import org.junit.Assert.;
public class HelloWorldTest{
@Test
public void testHello(){
Assert.assertEquals("Hello World",new HelloWorld().sayHello());
}
}
Save here
and then we need a pom file to manage
my own from previous projects to get over a
This is a basic framework pom
<?xml version="1.0" encoding="UTF-8"?>
4.0.0
after modification
<?xml version="1.0" encoding="UTF-8"?>
4.0.0
com.imooc.maven01
maven01-model
0.0.1-SNAPSHOT
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version> 4.10</version>
</dependency>
</dependencies>
Then there is the root directory
Then we open the command line
into the root directory
and then compile the project
error, syntax error
recompile errors continue
the original class was wrong
to remove the brackets
recompile
compiled successfully
Then the project, the more this
file to compile
and run our test case
mvn test
to continue to get an error saying can not find
my next re-clean
Without compiled