SSMフェーズで使用するjarパケット座標を学習する.
SSMフェーズで使用するjarパケット座標を学習する.前言 一、拿来主義.以降mavenプロジェクトを構築するには、以下のコードを持っていくだけでよいが、使用説明に従って、一部の内容 を置き換える. 使用説明: 二、バージョンロック方式を用いて依存衝突を解決する 三、いくつかの小さな穴 1.propertiesラベルのJDKバージョンの指定 2.servlet-apiとjsp-apiの2つのjarパッケージの問題
前言
mavenでJavaプロジェクトを統合するのは確かにとても香りがして、工事を構築するたびにここのpomをコピーするだけです.xmlコードでよい.でもまだいくつか注意が必要です
一、拿来主义後でmavenプロジェクトを構築するには、以下のコードを持っていくだけでいいですが、使用説明に従って、一部の内容を置き換えます.
使用方法:
使用説明:第1:最初の数行に
第二:プロジェクトのサブモジュールのpom.xmlには、親モジュールが誰であるかを表す
第三:ctrl+r、artifactID(必須)とgroupID(このオプション)の内容を置き換える
第四:インポートが完了し、mavenプロジェクトがリフレッシュされた後、xxx moduleがmavenプロジェクトによって削除されたとエラーが発生した場合、ローカルプロジェクトツリーからモジュールを削除しますか?このときは必ずNOを選び、xxx moduleのpomを選びます.xml、pomを右クリックxml->add as maven project
pom.xmlの完全なコードは次のとおりです.
二、バージョンロック方式で依存衝突を解決する
これはプロジェクトの異なるモジュール間のjarパケット依存のよくある欠点である.しかし、バージョンをロックするだけでこの問題を解決することができます.コードは次のとおりです.
三、いくつかの小さな穴
1.propertiesラベルのJDKバージョンの指定
もしここで1.8という帯を使っていたら.のバージョンでは、1.7 1.8などを記入します.ここでJDK 11、12を使用している場合は、11または12に直接記入します.
2.servlet-apiとjsp-apiの2つのjarパッケージの問題
この2つのjarパッケージは、常に1つの役割範囲providedと
でもJDK 12+tomcat 9+maven 3.5.2の環境では、providedを加えるとエラーが発生するので、ここでは役割ドメインを追加しません.
前言
mavenでJavaプロジェクトを統合するのは確かにとても香りがして、工事を構築するたびにここのpomをコピーするだけです.xmlコードでよい.でもまだいくつか注意が必要です
一、拿来主义後でmavenプロジェクトを構築するには、以下のコードを持っていくだけでいいですが、使用説明に従って、一部の内容を置き換えます.
使用方法:
使用説明:第1:最初の数行に
ラベル(modulesラベルはマルチモジュール構築用)が現れると、moduleの中で以前の工事のモジュールを削除し、新しい工事のモジュール名を加える必要がある.複数のモジュールがある場合は、
のサブラベルを複数追加します.間違っている場合は試してみてください.間違っていない場合は気にしないでください.第二:プロジェクトのサブモジュールのpom.xmlには、親モジュールが誰であるかを表す
ラベル(parentラベルはマルチモジュール構築用)がある.エラーが発生した場合はサブモジュールにparentラベルの構成を追加すればよい(追加しない場合はローカルcopyに割り当てられたサブモジュールのpom.xmlに行く)エラーが発生した場合は試して、エラーが発生しない場合は気にしない第三:ctrl+r、artifactID(必須)とgroupID(このオプション)の内容を置き換える
第四:インポートが完了し、mavenプロジェクトがリフレッシュされた後、xxx moduleがmavenプロジェクトによって削除されたとエラーが発生した場合、ローカルプロジェクトツリーからモジュールを削除しますか?このときは必ずNOを選び、xxx moduleのpomを選びます.xml、pomを右クリックxml->add as maven 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.0modelVersion>
<groupId>xxxxxxgroupId>
<artifactId>xxxxxxartifactId>
<version>1.0-SNAPSHOTversion>
<packaging>pompackaging>
<name>xxxxxx Maven Webappname>
<url>http://www.example.comurl>
<properties>
<project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
<maven.compiler.source>12maven.compiler.source>
<maven.compiler.target>12maven.compiler.target>
<spring.version>5.1.9.RELEASEspring.version>
<springmvc.version>5.1.9.RELEASEspringmvc.version>
<mybatis.version>3.5.2mybatis.version>
properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.mybatisgroupId>
<artifactId>mybatisartifactId>
<version>${mybatis.version}version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-webmvcartifactId>
<version>${springmvc.version}version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-contextartifactId>
<version>${spring.version}version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-coreartifactId>
<version>${spring.version}version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-aopartifactId>
<version>${spring.version}version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-webartifactId>
<version>${spring.version}version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-expressionartifactId>
<version>${spring.version}version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-beansartifactId>
<version>${spring.version}version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-aspectsartifactId>
<version>${spring.version}version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-context-supportartifactId>
<version>${spring.version}version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-testartifactId>
<version>${spring.version}version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-jdbcartifactId>
<version>${spring.version}version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-txartifactId>
<version>${spring.version}version>
dependency>
dependencies>
dependencyManagement>
<dependencies>
<dependency>
<groupId>org.mybatisgroupId>
<artifactId>mybatisartifactId>
dependency>
<dependency>
<groupId>org.mybatisgroupId>
<artifactId>mybatis-springartifactId>
<version>2.0.2version>
dependency>
<dependency>
<groupId>mysqlgroupId>
<artifactId>mysql-connector-javaartifactId>
<version>5.1.32version>
dependency>
<dependency>
<groupId>c3p0groupId>
<artifactId>c3p0artifactId>
<version>0.9.1.2version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-webmvcartifactId>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-contextartifactId>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-coreartifactId>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-aopartifactId>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-webartifactId>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-expressionartifactId>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-beansartifactId>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-aspectsartifactId>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-context-supportartifactId>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-testartifactId>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-jdbcartifactId>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-txartifactId>
dependency>
<dependency>
<groupId>junitgroupId>
<artifactId>junitartifactId>
<version>4.12version>
<scope>testscope>
dependency>
<dependency>
<groupId>javax.servletgroupId>
<artifactId>servlet-apiartifactId>
<version>2.5version>
dependency>
<dependency>
<groupId>javax.servlet.jspgroupId>
<artifactId>jsp-apiartifactId>
<version>2.2version>
dependency>
<dependency>
<groupId>javax.servletgroupId>
<artifactId>jstlartifactId>
<version>1.2version>
dependency>
<dependency>
<groupId>log4jgroupId>
<artifactId>log4jartifactId>
<version>1.2.17version>
dependency>
dependencies>
<build>
<finalName>xxxxxxfinalName>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-clean-pluginartifactId>
<version>3.1.0version>
plugin>
<plugin>
<artifactId>maven-resources-pluginartifactId>
<version>3.0.2version>
plugin>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-compiler-pluginartifactId>
<version>3.2version>
<configuration>
<source>12source>
<target>12target>
configuration>
plugin>
<plugin>
<artifactId>maven-surefire-pluginartifactId>
<version>2.22.1version>
plugin>
<plugin>
<artifactId>maven-war-pluginartifactId>
<version>3.2.2version>
plugin>
<plugin>
<artifactId>maven-install-pluginartifactId>
<version>2.5.2version>
plugin>
<plugin>
<artifactId>maven-deploy-pluginartifactId>
<version>2.8.2version>
plugin>
plugins>
pluginManagement>
<resources>
<resource>
<directory>src/main/javadirectory>
<includes>
<include>**/*.xmlinclude>
includes>
<filtering>truefiltering>
resource>
resources>
build>
project>
二、バージョンロック方式で依存衝突を解決する
これはプロジェクトの異なるモジュール間のjarパケット依存のよくある欠点である.しかし、バージョンをロックするだけでこの問題を解決することができます.コードは次のとおりです.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.mybatisgroupId>
<artifactId>mybatisartifactId>
<version>${mybatis.version}version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-webmvcartifactId>
<version>${springmvc.version}version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-contextartifactId>
<version>${spring.version}version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-coreartifactId>
<version>${spring.version}version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-aopartifactId>
<version>${spring.version}version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-webartifactId>
<version>${spring.version}version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-expressionartifactId>
<version>${spring.version}version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-beansartifactId>
<version>${spring.version}version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-aspectsartifactId>
<version>${spring.version}version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-context-supportartifactId>
<version>${spring.version}version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-testartifactId>
<version>${spring.version}version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-jdbcartifactId>
<version>${spring.version}version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-txartifactId>
<version>${spring.version}version>
dependency>
dependencies>
dependencyManagement>
三、いくつかの小さな穴
1.propertiesラベルのJDKバージョンの指定
<properties>
<project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
<maven.compiler.source>12maven.compiler.source>
<maven.compiler.target>12maven.compiler.target>
<spring.version>5.1.9.RELEASEspring.version>
<springmvc.version>5.1.9.RELEASEspringmvc.version>
<mybatis.version>3.5.2mybatis.version>
properties>
もしここで1.8という帯を使っていたら.のバージョンでは、1.7 1.8などを記入します.ここでJDK 11、12を使用している場合は、11または12に直接記入します.
2.servlet-apiとjsp-apiの2つのjarパッケージの問題
この2つのjarパッケージは、常に1つの役割範囲providedと
<scope>providedscope>
でもJDK 12+tomcat 9+maven 3.5.2の環境では、providedを加えるとエラーが発生するので、ここでは役割ドメインを追加しません.