zoukankan      html  css  js  c++  java
  • Intellij-Idea Maven SSH项目的搭建

    添加阿里云镜像

    在.m2/settings.xml中,标签内添加:

    	<mirror>
    		<id>nexus-aliyun</id>
    		<name>Nexus aliyun</name>
    		<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
    		<mirrorOf>*</mirrorOf>
    	</mirror>
      </mirrors>
    

    之后就可以用阿里云提供的jar包了,更新速度还是蛮快的。

    Maven repository

    网站推荐用mvnrepository.com,访问速度很快,查各类jar包很方便,即使不用maven去这里下载jar包也是极好的。

    创建maven项目

    对于idea,你可以新建maven web项目,也可以干脆就在已有项目添加maven框架支持。创建后,项目会自动变为maven项目,现在需要处理的就是Lib的问题了。

    修改pom.xml

    为了方便大家,我直接提供集成了Springmvc,Spring,Hibernate,Jackson,Redis以及一些相关的包的pom文件,具体版本可能需要自己改。我为了方便添加了统一变量。修改pom可以实现jdk的版本控制和添加lib支持。

    <?xml version="1.0" encoding="UTF-8"?>
    <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>SSH-demo</groupId>
        <artifactId>SSH-demo</artifactId>
        <version>1.0-SNAPSHOT</version>
        <!--以上内容根据自己的项目确定,通常ideak可以自动建立完毕-->
        <properties>
            <maven.compiler.source>1.8</maven.compiler.source>
            <maven.compiler.target>1.8</maven.compiler.target>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <jdbc.driver.version>5.1.42</jdbc.driver.version>
            <org.springframework.version>4.3.8.RELEASE</org.springframework.version>
            <com.fasterxml.jackson>2.8.8</com.fasterxml.jackson>
        </properties>
    
        <dependencies>
            <!--commons依赖-->
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-pool2</artifactId>
                <version>2.4.2</version>
            </dependency>
            <dependency>
                <groupId>commons-codec</groupId>
                <artifactId>commons-codec</artifactId>
                <version>1.10</version>
            </dependency>
            <dependency>
                <groupId>commons-logging</groupId>
                <artifactId>commons-logging</artifactId>
                <version>1.2</version>
            </dependency>
            <!--jackson依赖-->
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-core</artifactId>
                <version>${com.fasterxml.jackson}</version>
            </dependency>
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-databind</artifactId>
                <version>${com.fasterxml.jackson}</version>
            </dependency>
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-annotations</artifactId>
                <version>${com.fasterxml.jackson}</version>
            </dependency>
            <!--redis依赖-->
            <dependency>
                <groupId>redis.clients</groupId>
                <artifactId>jedis</artifactId>
                <version>2.9.0</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.data</groupId>
                <artifactId>spring-data-commons</artifactId>
                <version>1.13.3.RELEASE</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.data</groupId>
                <artifactId>spring-data-redis</artifactId>
                <version>1.8.3.RELEASE</version>
            </dependency>
            <!--spring和springmvc依赖-->
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-web</artifactId>
                <version>${org.springframework.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-webmvc</artifactId>
                <version>${org.springframework.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-websocket</artifactId>
                <version>${org.springframework.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-webmvc-portlet</artifactId>
                <version>${org.springframework.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-orm</artifactId>
                <version>${org.springframework.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-jdbc</artifactId>
                <version>${org.springframework.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-aspects</artifactId>
                <version>${org.springframework.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-instrument</artifactId>
                <version>${org.springframework.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-instrument-tomcat</artifactId>
                <version>${org.springframework.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-jms</artifactId>
                <version>${org.springframework.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-test</artifactId>
                <version>${org.springframework.version}</version>
            </dependency>
            <!--Hibernate依赖-->
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-core</artifactId>
                <version>5.2.10.Final</version>
            </dependency>
            <dependency>
                <groupId>org.hibernate.javax.persistence</groupId>
                <artifactId>hibernate-jpa-2.1-api</artifactId>
                <version>1.0.0.Final</version>
            </dependency>
            <!--其他依赖-->
            <dependency>
                <groupId>org.jboss</groupId>
                <artifactId>jandex</artifactId>
                <version>2.0.3.Final</version>
            </dependency>
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>${jdbc.driver.version}</version>
            </dependency>
            <dependency>
                <groupId>aopalliance</groupId>
                <artifactId>aopalliance</artifactId>
                <version>1.0</version>
            </dependency>
        </dependencies>
    </project>
    

    修改项目配置

    由于我们用原项目迁移,以及后续添加了很多lib,这时候必须去项目的Artifacts看一下,确认一下lib是否全部添加,如果没有的话,最简单的方法是重新生成Artifacts。

  • 相关阅读:
    KETTLE封装
    基于MODBUS-RTU协议的串口编程
    阿里DRUID 配置说明及分析
    CopyOnWriteArrayList集合排序异常问题
    CopyOnWriteArrayList集合线程安全解释
    JAR包数字签名与验证
    MySQL中select * for update锁表的范围
    Kettle文本文件输出和输入控件使用中,换行符导致的问题处理
    UAP如何根据DeviceFamily显示不同的页面
    Windows 10 响应式设计和设备友好的开发
  • 原文地址:https://www.cnblogs.com/cielosun/p/6789851.html
Copyright © 2011-2022 走看看