开发环境搭建-Spring Tool Suite安装

在这里记录一下自己搭建spring开发环境的过程。要求电脑必须联网。

1,下载并安装jdk8。安装过程这里不详细说明了。

2,下载并安装maven。
2.1 下载maven
下载地址是http://maven.apache.org/download.cgi
我这里下载的可以直接在window上直接用的版本,apache-maven-3.5.2-bin.zip。
2.2 解压maven
在磁盘上新建一个文件夹,用来存放解压后的maven。我这里创建H:\maven文件夹。把apache-maven-3.5.2解压到maven文件夹中。然后再maven文件夹中新建respository文件夹,用来作为maven的仓库。
2.3 配置maven仓库
进入apache-maven-3.5.2文件夹中,进入conf文件夹,会看到有settings.xml文件,这个就是maven的配置文件。用写字板打开settings.xml,对配置进行修改。
找到/path/to/local/repo
,这是本地仓库的位置,我们修改成自己的文件夹H:\maven\respository

2.4 设置网络代理(能直接访问网络,跳过这步)
如果公司需要使用代理才能上网,还需要修改proxies。找到proxies标签,修改里面对应的内容。


optional
true
http
proxyuser
proxypass
proxy.host.net
80
local.net|some.host.com



2.5 设置镜像
镜像用来加速下载jar包的速度,设置如下

<mirrors>
<mirror>
<id>alimavenid>
<name>aliyun mavenname>
<url>http://maven.aliyun.com/nexus/content/groups/public/url>
<mirrorOf>centralmirrorOf>
mirror>
<mirror>
<id>repo2id>
<mirrorOf>centralmirrorOf>
<name>Human Readable Name for this Mirror.name>
<url>http://repo2.maven.org/maven2/url>
mirror>
<mirror>
<id>uiid>
<mirrorOf>centralmirrorOf>
<name>Human Readable Name for this Mirror.name>
<url>http://uk.maven.org/maven2/url>
mirror>
<mirror>
<id>ibiblioid>
<mirrorOf>centralmirrorOf>
<name>Human Readable Name for this Mirror.name>
<url>http://mirrors.ibiblio.org/pub/mirrors/maven2/url>
mirror>
<mirror>
<id>jboss-public-repository-groupid>
<mirrorOf>centralmirrorOf>
<name>JBoss Public Repository Groupname>
<url>http://repository.jboss.org/nexus/content/groups/publicurl>
mirror>     
mirrors>

2.6 设置默认jdk版本
maven默认使用jdk1.5,这里修改成默认使用1.8版本

<profile>    
    <id>jdk-1.8id>    
     <activation>    
          <activeByDefault>trueactiveByDefault>    
          <jdk>1.8jdk>    
      activation>    
<properties>    
<maven.compiler.source>1.8maven.compiler.source>    
<maven.compiler.target>1.8maven.compiler.target>    
<maven.compiler.compilerVersion>1.8maven.compiler.compilerVersion>    
properties>    
profile>

到这里settings.xml就配置好了。
我的设置如下,大家可以自行修改。

.
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <localRepository>H:\maven\respositorylocalRepository>
  <pluginGroups>
  pluginGroups>
  <proxies>
    <proxy>
      <id>optionalid>
      <active>trueactive>
      <protocol>httpprotocol>
      <host>proxy3.xx.xxxxhost>
      <port>8080port>
      <nonProxyHosts>local.net|some.host.comnonProxyHosts>
    proxy>    
  proxies>
  <servers>
  servers>
<mirrors>
<mirror>
<id>alimavenid>
<name>aliyun mavenname>
<url>http://maven.aliyun.com/nexus/content/groups/public/url>
<mirrorOf>centralmirrorOf>
mirror>
<mirror>
<id>repo2id>
<mirrorOf>centralmirrorOf>
<name>Human Readable Name for this Mirror.name>
<url>http://repo2.maven.org/maven2/url>
mirror>
<mirror>
<id>uiid>
<mirrorOf>centralmirrorOf>
<name>Human Readable Name for this Mirror.name>
<url>http://uk.maven.org/maven2/url>
mirror>
<mirror>
<id>ibiblioid>
<mirrorOf>centralmirrorOf>
<name>Human Readable Name for this Mirror.name>
<url>http://mirrors.ibiblio.org/pub/mirrors/maven2/url>
mirror>
<mirror>
<id>jboss-public-repository-groupid>
<mirrorOf>centralmirrorOf>
<name>JBoss Public Repository Groupname>
<url>http://repository.jboss.org/nexus/content/groups/publicurl>
mirror>     
mirrors>
  <profiles>
<profile>    
    <id>jdk-1.8id>    
     <activation>    
          <activeByDefault>trueactiveByDefault>    
          <jdk>1.8jdk>    
      activation>    
<properties>    
<maven.compiler.source>1.8maven.compiler.source>    
<maven.compiler.target>1.8maven.compiler.target>    
<maven.compiler.compilerVersion>1.8maven.compiler.compilerVersion>    
properties>    
profile>
profiles>
settings>

3 下载配置Spring Tool Suite
3.1 下载Spring Tool Suite
Spring Tool Suite是为开发spring应用定制的eclipse。下载地址https://spring.io/tools/sts/all/
下载windows版本,解压得到sts-bundle文件夹。sts-bundle文件夹内有三个文件夹。进入sts-bundle下的sts-3.9.1.RELEASE文件夹,运行STS.exe,便启动了Spring Tool Suite。
3.2 修改Spring Tool Suite字体和编码
和eclipse一样。点击window->preferences,进入preferences对话框。在对话框左边点开General->Appearance->Colors And Fonts。在右边选择Basic->Text Font,点击edit进入编辑页面,设置自己喜欢的字体大小和样式。
开发环境搭建-Spring Tool Suite安装_第1张图片
开发环境搭建-Spring Tool Suite安装_第2张图片
然后,设置默认编码为utf-8。还是在preferences对话框中,左边点击General->workspace,右边向下拉,text file encoding选择other utf-8。
开发环境搭建-Spring Tool Suite安装_第3张图片

3.3 配置maven
在preferences对话框中,选择maven->Installations,在右边点击add
开发环境搭建-Spring Tool Suite安装_第4张图片
在新弹出的对话框中点击Directory按钮。选择我们解压maven 的路径
开发环境搭建-Spring Tool Suite安装_第5张图片
选择后Installation name会自动填入值。点击finish。
然后点击Apply and Close
开发环境搭建-Spring Tool Suite安装_第6张图片

配置maven仓库
在preferences对话框中,选择maven->UserSerttings。在UserSettings中选择maven中修改好的settings.xml文件,然后保存。
开发环境搭建-Spring Tool Suite安装_第7张图片

到这里开发环境算搭建好了,下面开始测试

你可能感兴趣的:(spring学习)