摘要:本文将带你了解WEBAPP开发之eclipse Maven 使用记录 ------ 建立 webapp项目,希望本文对大家学微信有所帮助。
本文将带你了解WEBAPP开发之eclipse Maven 使用记录 ------ 建立 webapp项目,希望本文对大家学微信有所帮助。
eclipse Maven 使用记录 ------ 建立 webapp项目
maven 建立 webapp 项目 有2种方式 , 1.在原先app上转换为webapp项目 2.建立maven项目的时候 filter 选择webapp 该选项把webapp文件目录建好,其他的还是要自己配。。。。。采用将原先的app项目改成 webapp项目 1.改变项目,动态web工程让项目成此结构eclipse buliders 配置文件<?xml version="1.0" encoding="UTF-8"?> <projectDescription> <name>mmvc</name> <comment></comment> <projects> </projects> <buildSpec> <buildCommand> <name>org.eclipse.wst.jsdt.core.javascriptValidator</name> <arguments> </arguments> </buildCommand> <buildCommand> <name>org.eclipse.jdt.core.javabuilder</name> <arguments> </arguments> </buildCommand> <buildCommand> <name>org.eclipse.wst.common.project.facet.core.builder</name> <arguments> </arguments> </buildCommand> <buildCommand> <name>org.eclipse.wst.validation.validationbuilder</name> <arguments> </arguments> </buildCommand> <buildCommand> <name>org.eclipse.m2e.core.maven2Builder</name> <arguments> </arguments> </buildCommand> </buildSpec> <natures> <nature>org.eclipse.m2e.core.maven2Nature</nature> <nature>org.eclipse.jem.workbench.JavaEMFNature</nature> <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature> <nature>org.eclipse.wst.common.project.facet.core.nature</nature> <nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.wst.jsdt.core.jsNature</nature> </natures> </projectDescription> 项目 工程下 .settings ---- .jsdtscope文件修改 java脚本路径<?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="/src/main/webapp"/> //改这里 <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject"> <attributes> <attribute name="hide" value="true"/> </attributes> </classpathentry> <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/> <classpathentry kind="output" path=""/> </classpath> 配置 web context root deploy-path 目录如果项目原先为 web工程 ,这时候要换目录则需要进入配置文件改动项目 工程下 .settings ---- org.eclipse.wst.common.component文件修改 发布目录<?xml version="1.0" encoding="UTF-8"?> <project-modules id="moduleCoreId" project-version="1.5.0"> <wb-module deploy-name="mmvc"> <wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resource"/> <property name="context-root" value="mmvc"/> <property name="java-output-path" value="/mmvc/build/classes"/> </wb-module> </project-modules> 文件目录建好之后 , 为了让java 脚本及配置文件能 auto bulid 需要配置 这2个目自动编译至webapp发布目录 /classesok web项目基本构建完成2.pom.xml 配置 web 所需要的环境<project xmlns="//maven.apache.org/POM/4.0.0" xmlns:xsi="//www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="//maven.apache.org/POM/4.0.0 //maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>mmvc</groupId> <artifactId>mmvc</artifactId> <version>1</version> <packaging>war</packaging> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <spring.version>3.0.5.RELEASE</spring.version> </properties> <dependencies> <dependency> <groupId>org.apache.openejb</groupId> <artifactId>javaee-api</artifactId> <version>5.0-1</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.faces</groupId> <artifactId>jsf-api</artifactId> <version>1.2_04</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>2.1</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.faces</groupId> <artifactId>jsf-impl</artifactId> <version>1.2_04</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version> <scope>runtime</scope> </dependency> </dependencies> <build> <!-- 列出所依赖的 plugin mvn自动选择包含的 --> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> <plugin> <groupId>org.eclipse.m2e</groupId> <artifactId>lifecycle-mapping</artifactId> <version>1.0.0</version> <configuration> <lifecycleMappingMetadata> <pluginExecutions> <pluginExecution> <pluginExecutionFilter> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <versionRange>[2.0,)</versionRange> <goals> <goal>copy-dependencies</goal> </goals> </pluginExecutionFilter> <action> <ignore /> </action> </pluginExecution> </pluginExecutions> </lifecycleMappingMetadata> </configuration> </plugin> </plugins> </pluginManagement> <plugins> <!-- remove jar plugins --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-clean-plugin</artifactId> <executions> <execution> <id>clean</id> <phase>install</phase> <goals> <goal>clean</goal> </goals> <configuration> <directory>/src/main/webapp/WEB-INF/lib</directory> </configuration> </execution> </executions> </plugin> <!-- copy jar plugins --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <id>copy-dependencies</id> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory>src/main/webapp/WEB-INF/lib</outputDirectory> <excludeTransitive>false</excludeTransitive> <stripVersion>false</stripVersion> <!-- 复制jar 的时候去掉版本信息 true : 去掉 false: 不去掉 --> <includeScope>runtime</includeScope> </configuration> </execution> </executions> </plugin> </plugins> </build> </project>
以上配置包含 javeee 自带的jar , springmvc 框架 所需jar ,可以从maven远程仓库获取至本地服务器仓库 ,再 从maven仓库获取另包含 自动部署的时候 copy jar到 发布目录下的lib目录下ok 需要生成 package的时候 会自动生成到 target 目录下并打成war包 maven package执行的时候会遇到jdk版本不对的问题 :原因是 maven所指定的jdk版本与项目使用的jdk版本不一致参见 maven 使用记录之修改 maven默
本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注职坐标移动开发之webapp频道!
您输入的评论内容中包含违禁敏感词
我知道了
请输入正确的手机号码
请输入正确的验证码
您今天的短信下发次数太多了,明天再试试吧!
我们会在第一时间安排职业规划师联系您!
您也可以联系我们的职业规划师咨询:
版权所有 职坐标-一站式IT培训就业服务领导者 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
沪公网安备 31011502005948号