• 新建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文件是否是自己需要的。

  • 相关阅读:
    【JZOJ3213】【SDOI2013】直径
    【JZOJ3211】【SDOI2013】随机数生成器
    【巨人的步伐以及人类的进击】BSGS algorithm
    【JZOJ2758】【SDOI2012】走迷宫(labyrinth)
    【JZOJ4964】【GDKOI2017模拟1.21】Rhyme
    【JZOJ3875】【NOIP2014八校联考第4场第2试10.20】星球联盟(alliance)
    【JZOJ3873】【NOIP2014八校联考第4场第2试10.20】乐曲创作(music)
    【JZOJ3887】【长郡NOIP2014模拟10.22】字符串查询
    【JZOJ3886】【长郡NOIP2014模拟10.22】道路维护
    django 模版-标签-视图-csrf-token-模版继承-HTML过滤器
  • 原文地址:https://www.cnblogs.com/ysloong/p/6094575.html
Copyright © 2020-2023  润新知