概要
本文介绍使用IntelliJ IDEA搭Spring框架建源代码环境,用于源代码阅读与调试。
环境搭建
2.根据说明导入IntelliJ IDEA
根据源代码文件中的想法导入说明进行操作,说明文件为源代码根目录的import-into-idea.md
<前>
<代码>预编译“spring-oxm”与“。/gradlew: spring-oxm: compileTestJava
导入IntelliJ(文件→新→项目从现有来源→导航到目录→选择build.gradle)
当提示排除“spring-aspects”模块(或以后通过文件导入→项目结构→模块)
代码
代码>
<李> 1。需要预编译spring-oxm,通过控制台,进入到Spring框架目录,运行命令gradlew: spring-oxm: compileTestJava。
注:Spring框架是通过Gradle进行的编译打包,故需要提前安装它
<李> 2。导入至想法中,操作方法:文件→新→项目从现有来源→导航到目录→选择build.gradle
测试演示在源代码项目目录下,本人直接创建了一个Maven测试项目,并创建了一个简单的Bean注册于获取的例子。
<编辑id=" h6-pom-xml ">
李pom.xml 编辑> >
<前>
<代码类=" lang-xml "> & lt; ?xml version=" 1.0 " encoding=" utf - 8 " ?比;
& lt;项目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”比;
& lt; modelVersion> 4.0.0
& lt; groupId> cn.daiwuliang
& lt; artifactId> demo
& lt; version> 1.0 -snapshot
& lt; name> demo
& lt; !——FIXME改变项目的网站比;
& lt; url> http://www.example.com</url>
& lt; properties>
& lt; project.build.sourceEncoding> UTF-8
& lt; maven.compiler.source> 1.8 & lt;/maven.compiler.source>
& lt; maven.compiler.target> 1.8 & lt;/maven.compiler.target>
& lt;/properties>
& lt; dependencies>
& lt; dependency>
& lt; groupId> junit
& lt; artifactId> junit
& lt; version> 4.11 & lt;/version>
& lt; scope> test
& lt;/dependency>
& lt; !——引入通用日志依赖——比;
& lt; dependency>
& lt; groupId> commons-logging
& lt; artifactId> commons-logging
& lt; version> 1.2 & lt;/version>
& lt;/dependency>
& lt;/dependencies>
& lt; build>
& lt; pluginManagement> & lt; !——锁定,避免使用Maven插件版本默认值(可能会搬到父pom)——比;
& lt; plugins>
& lt; !——干净的生命周期,看到https://maven.apache.org/ref/current/maven-core/lifecycles.html clean_Lifecycle——比;
& lt; plugin>
& lt; artifactId> maven-clean-plugin
& lt; version> 3.1.0
& lt;/plugin>
& lt; !——缺省生命周期,罐子包装:看到https://maven.apache.org/ref/current/maven-core/default-bindings.html Plugin_bindings_for_jar_packaging——比;
& lt; plugin>
& lt; artifactId> maven-resources-plugin
& lt; version> 3.0.2
& lt;/plugin>
& lt; plugin>
& lt; artifactId> maven-compiler-plugin
& lt; version> 3.8.0
& lt;/plugin>
& lt; plugin>
& lt; artifactId> maven-surefire-plugin
& lt; version> 2.22.1
& lt;/plugin>
& lt; plugin>
& lt; artifactId> maven-jar-plugin
& lt; version> 3.0.2
& lt;/plugin>
& lt; plugin>
& lt; artifactId> maven-install-plugin