注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

流星永恒的博客

JSF,Facelets,Rich(Prime)Faces,和java的笔记

 
 
 

日志

 
 

Eclipse(4.2) maven(3.0.4--m2e) integrate with tomcat 7 (win7)  

2012-08-04 14:14:26|  分类: Maven3 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

1.Install maven plugin(The picture following showed for you means you maven plugin "Maven Integration for Eclipse" was already installed)

Eclipse(4.2) maven(3.0.4--m2e) integrate with tomcat 7 (win7) - yyq2007aa - 流星永恒的博客

 

2. Add tomcat 7 server to eclipse IDE(On picture you can find tomcat version information.)

Eclipse(4.2) maven(3.0.4--m2e) integrate with tomcat 7 (win7) - yyq2007aa - 流星永恒的博客
 

 Change publishing option and Server Locations option.

Eclipse(4.2) maven(3.0.4--m2e) integrate with tomcat 7 (win7) - yyq2007aa - 流星永恒的博客

 3. Create a maven project, and config it  as a jsf project.

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/xsd/maven-4.0.0.xsd">
 <modelVersion>4.0.0</modelVersion>

 <groupId>com.demo</groupId>
 <artifactId>test1</artifactId>
 <version>1.0-SNAPSHOT</version>
 <packaging>war</packaging>
 <name>Test1</name>

 <properties>
  <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  <project.build.finalName>${project.name}</project.build.finalName>
  <dependency.scope>compile</dependency.scope>
 </properties>

 <dependencies>
  <dependency>
   <groupId>javax</groupId>
   <artifactId>javaee-web-api</artifactId>
   <version>6.0</version>
   <scope>provided</scope>
  </dependency>
  <dependency>
   <groupId>com.sun.faces</groupId>
   <artifactId>jsf-api</artifactId>
   <version>2.1.11</version>
   <scope>compile</scope>
  </dependency>
  <dependency>
   <groupId>com.sun.faces</groupId>
   <artifactId>jsf-impl</artifactId>
   <version>2.1.11</version>
   <scope>compile</scope>
  </dependency>
  <!-- for JSF 2.x -->
  <dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>jstl</artifactId>
   <version>1.2</version>
  </dependency>
  <dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>servlet-api</artifactId>
   <version>2.5</version>
   <scope>provided</scope>
  </dependency>
  <dependency>
   <groupId>javax.el</groupId>
   <artifactId>el-api</artifactId>
   <version>2.2</version>
  </dependency>

  <dependency>
   <groupId>org.slf4j</groupId>
   <artifactId>slf4j-api</artifactId>
   <version>1.6.1</version>
  </dependency>

  <dependency>
   <groupId>org.slf4j</groupId>
   <artifactId>slf4j-log4j12</artifactId>
   <version>1.6.1</version>
  </dependency>

  <dependency>
   <groupId>log4j</groupId>
   <artifactId>log4j</artifactId>
   <version>1.2.16</version>
   <exclusions>
    <exclusion>
     <groupId>javax.mail</groupId>
     <artifactId>mail</artifactId>
    </exclusion>
    <exclusion>
     <groupId>javax.jms</groupId>
     <artifactId>jms</artifactId>
    </exclusion>
    <exclusion>
     <groupId>com.sun.jdmk</groupId>
     <artifactId>jmxtools</artifactId>
    </exclusion>
    <exclusion>
     <groupId>com.sun.jmx</groupId>
     <artifactId>jmxri</artifactId>
    </exclusion>
   </exclusions>
  </dependency>
 </dependencies>

 <build>
  <finalName>${project.name}</finalName>
  <defaultGoal>install</defaultGoal>

  <resources>
   <resource>
    <targetPath></targetPath>
    <directory>src/main/resources</directory>
    <filtering>true</filtering>
   </resource>
  </resources>

  <plugins>

   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.3.2</version>
    <configuration>
     <source>1.7</source>
     <target>1.7</target>
     <encoding>${project.build.sourceEncoding}</encoding>
     <compilerArguments>
      <endorseddirs>${endorsed.dir}</endorseddirs>
     </compilerArguments>
    </configuration>
   </plugin>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.1.1</version>
    <configuration>
     <webappDirectory>target/${project.name}</webappDirectory>
     <warSourceDirectory>src/main/webapp</warSourceDirectory>
     <failOnMissingWebXml>false</failOnMissingWebXml>
    </configuration>
   </plugin>
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.1</version>
    <executions>
     <execution>
      <phase>validate</phase>
      <goals>
       <goal>copy</goal>
      </goals>
      <configuration>
       <outputDirectory>${endorsed.dir}</outputDirectory>
       <silent>true</silent>
       <artifactItems>
        <artifactItem>
         <groupId>javax</groupId>
         <artifactId>javaee-endorsed-api</artifactId>
         <version>6.0</version>
         <type>jar</type>
        </artifactItem>
       </artifactItems>
      </configuration>
     </execution>
    </executions>
   </plugin>
  </plugins>
  <pluginManagement>
   <plugins>
    <!--This plugin's configuration is used to store Eclipse m2e settings
     only. It has no influence on the Maven build itself. -->
    <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.1,)
          </versionRange>
          <goals>
           <goal>copy</goal>
           <goal>
            copy-dependencies
           </goal>
          </goals>
         </pluginExecutionFilter>
         <action>
          <ignore></ignore>
         </action>
        </pluginExecution>
       </pluginExecutions>
      </lifecycleMappingMetadata>
     </configuration>
    </plugin>
   </plugins>
  </pluginManagement>
 </build>

</project>

project struture maybe like this:
Eclipse(4.2) maven(3.0.4--m2e) integrate with tomcat 7 (win7) - yyq2007aa - 流星永恒的博客
Config "Run Configurations" and run it(Project menu --> Run as --> Maven build)
Eclipse(4.2) maven(3.0.4--m2e) integrate with tomcat 7 (win7) - yyq2007aa - 流星永恒的博客
 
Config source output directory to "target/Test1/WEB-INF/classes"(If can't find the folder, refresh project)

Eclipse(4.2) maven(3.0.4--m2e) integrate with tomcat 7 (win7) - yyq2007aa - 流星永恒的博客
 
Config tomcat 7 to deploy the project, open server.xml file in Servers project(When you added a server this project is existed)
Eclipse(4.2) maven(3.0.4--m2e) integrate with tomcat 7 (win7) - yyq2007aa - 流星永恒的博客
 
Add this line to deploy project(nested in Host XML element):
<Context docBase="D:\projects\Test1\target\Test1" path="/Test" reloadable="false"></Context>\
"D:\projects\Test1" is project base path, "target\Test1" will be generated after maven build project.
4. Debugging
Make a breakpoint in your java code(In my demo project, I maked one in jsf managed bean, and triggle it by submitting a jsf action.)
 
Start tomcat server in debug mode.
 
Open your browser and open url "http://localhost:8080/Test/index.jsf", then click the button and submit an action:
Eclipse(4.2) maven(3.0.4--m2e) integrate with tomcat 7 (win7) - yyq2007aa - 流星永恒的博客
The IDE find the breakpoint but not found the source code, then click "edit source lookup path" button to add project source path:
 
Eclipse(4.2) maven(3.0.4--m2e) integrate with tomcat 7 (win7) - yyq2007aa - 流星永恒的博客
 
 
Eclipse(4.2) maven(3.0.4--m2e) integrate with tomcat 7 (win7) - yyq2007aa - 流星永恒的博客
 
 
OK, then go to breakpoint
Eclipse(4.2) maven(3.0.4--m2e) integrate with tomcat 7 (win7) - yyq2007aa - 流星永恒的博客
 
If you delete a line of method "say", you don't need redepoly project util it taking effect.

That's it.
  评论这张
 
阅读(2782)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017