The creation maven maven project in eclipse

1, Maven plugin for Eclipse has been built.

2, set the Maven plugin: Window-> Preferences-> Maven
①installations: specify the location of Maven core program. The default is a plug-in that comes with Maven program, instead of our own unpack that.
②user settings: specify the location of Maven core program conf / settings.xml file, and then obtain location of the local repository.

3, the basic operation
① create Maven project version of the Java
check on the Create a simple project when you create (skip archetype selection)

Maven project I created using JDK1.7, open Maven core program settings.xml file, find the profiles tag, add the following configuration, you can change

      <profile>
        <id>jdk-1.7</id>
        <activation>
            <activeByDefault>true</activeByDefault>
            <jdk>1.7</jdk>
        </activation>
        <properties>
            <maven.compiler.source>1.7</maven.compiler.source>
            <maven.compiler.target>1.7</maven.compiler.target>
            <maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion>
        </properties>
    </profile>

② create Maven project version of the Web 

(1) New Maven project when, Packaging selected war 

(2) adjust the web directory structure, right click on the project -> properties-> Project Facets -> check remove the Dynamic Web Module, and Apply -> re-check the Dynamic Web Module -> Click Further configuration available -> Modify Content directory is src / main / webapp -> Apply to generate dynamic Web directory structure that is on the Maven project

(3) New jsp files found error: at The the superclass for "javax.servlet.http.HttpServlet" WAS not found at The ON the Java Build Path
because of the lack Tomcat runtime environment
to Maven Add:
add pom.xml file

(4)jsp写入EL表达式时发现报错:javax.servlet.jsp cannot be resolved to a type 
将JSPAPI导入 
在pom.xml文件中添加 

注意:scope一定要是provided,不然jar包冲突,运行时会报空指针异常

③执行Maven命令 
选中pom.xml 右键 Run As->Maven build…->Goals->输入 compile ->点击 run

Guess you like

Origin www.cnblogs.com/xiximayou/p/12234138.html