zoukankan      html  css  js  c++  java
  • 新建maven工程问题001

    这周一直在研究SpringMVC+Mybatis,有些心得,记录一下。

    Ⅰ:建maven遇到的问题。

      1.1 新建maven时选中【Create a simple project】这样,后面【Packaging】选项有【war/pom/jar】可供选择。

      1.2 新建maven时没有web.xml文件,会报错方法一是从别的项目copy过来一份

        方法二:【Project Facets】取消【Dynamic web Module】并且将【Java】选项调到1.6以上,选【OK】

            重新选中【Project Facts】中【Dynamic web Module】,在下面有一个【Futher Configuration aviable】

            点击后,选中【Generate web.xml deployment】就会自动生成web.xml

            同时将WebContent换成-》src/main/webapp

            最后确认【Deployment Assembly】中 src/main/webapp 后为“/”项目的根目录

      1.3 在maven里使用【${spring.version}】,因为在上边【Properties】属性里,定义了全局变量。

            <properties>
               <spring.version>4.0.2.RELEASE</spring.version>
             </properties>

      1.4 使用了build插件的一个理解:没有加入这个声明时,是按照jdk1.3来编译的

          参考:http://www.infoq.com/cn/news/2011/04/xxb-maven-7-plugin

          <build> 
              <plugins> 
                  <plugin> 
                      <groupId>org.apache.maven.plugins</groupId> 
                      <artifactId>maven-compiler-plugin</artifactId> 
                      <version>3.3</version> 
                      <configuration> 
                          <!-- 指定source和target的版本 -->                
                          <source>1.8</source>  =<source>${jdk.version}</source>
                          <target>1.8</target>   =<targer>${jdk.version}</targer>
                      </configuration> 
                  </plugin> 
              </plugins> 
          </build>

    Ⅱ:建spring工程需要的jar包


    <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.ssm</groupId>
      <artifactId>ssm</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <packaging>war</packaging>
      
      <properties>
          <!-- spring版本号 -->
          <spring.version>3.2.0.RELEASE</spring.version> 
      </properties>
      
      <dependencies>
      
          <dependency>     
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>${spring.version}</version>
        </dependency>    
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aspects</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
        </dependency>   
        <dependency> 
            <groupId>org.springframework</groupId> 
            <artifactId>spring-context-support</artifactId> 
            <version>${spring.version}</version> 
            </dependency> 
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
        </dependency>    
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-expression</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>
    
        <!-- mysql数据库驱动 -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.6</version>
        </dependency>
        
        <!-- mybatis的jar -->
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
            <version>3.2.7</version>
        </dependency>
        
        <!-- mybatis和spring的整合包 -->
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis-spring</artifactId>
            <version>1.2.2</version>
        </dependency>    
            
        <!-- 导入jdbc连接池 -->
        <dependency> 
            <groupId>commons-dbcp</groupId> 
            <artifactId>commons-dbcp</artifactId> 
            <version>1.2.2</version> 
        </dependency>
        <!-- jstl标签 -->
        <dependency> 
            <groupId>jstl</groupId> 
            <artifactId>jstl</artifactId> 
            <version>1.2</version> 
        </dependency>
        
        <!-- json与java对象转换jar -->
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>1.9.2</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>1.9.2</version>
        </dependency>   
        
        <!-- mybatis 需要的jar @Start-->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.5</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.5</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.0-rc1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>2.0-rc1</version>
        </dependency>
        <dependency>
            <groupId>org.javassist</groupId>
            <artifactId>javassist</artifactId>
            <version>3.17.1-GA</version>
        </dependency>
        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib</artifactId>
            <version>2.2.2</version>
        </dependency>
        <dependency>
            <groupId>asm</groupId>
            <artifactId>asm</artifactId>
            <version>3.3.1</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.1.1</version>
        </dependency>
        <!-- mybatis 需要的jar @End-->   
      </dependencies>

    <repositories>
      	<repository>
      		<id>aliyun-nexus</id>
      		<name>Nexus</name>
      		<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
      	</repository>
      </repositories>
      <pluginRepositories>
      	<pluginRepository>
      		<id>aliyun-nexus</id>
      		<name>Nexus</name>
      		<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
      	</pluginRepository>
      </pluginRepositories>
      
      
      <build>  
        <plugins>  
            <plugin>  
                <groupId>org.apache.maven.plugins</groupId>  
                <artifactId>maven-compiler-plugin</artifactId>  
                <version>3.3</version>  
                <configuration>  
                    <!-- 指定source和target的版本 -->                 
                    <source>1.8</source>  
                    <target>1.8</target>  
                </configuration>  
            </plugin>  
        </plugins>  
    </build>

    </project>

    Ⅲ:切换workspace时,要检查setting.xml文件是否是自己需要的。

  • 相关阅读:
    隐藏导航练习
    分层导航
    做一个问题,如果输入的答案正确则弹出正确,错误弹出错误
    同意按钮,倒计时10秒
    golang strings
    seek指针大文件上传
    go文件操作大全
    zipimport.ZipImportError: can't decompress data; zlib not available 解决办法
    centos 安装redis自启动要点
    golang 文件读取
  • 原文地址:https://www.cnblogs.com/ysloong/p/6094575.html
Copyright © 2011-2022 走看看