您的位置:首页 > 编程语言 > Java开发

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

2017-12-08 16:14 344 查看
在这里记录一下自己搭建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,对配置进行修改。

找到
<localRepository>/path/to/local/repo</localRepository>
,这是本地仓库的位置,我们修改成自己的文件夹
<localRepository>H:\maven\respository</localRepository>


2.4 设置网络代理(能直接访问网络,跳过这步)

如果公司需要使用代理才能上网,还需要修改proxies。找到proxies标签,修改里面对应的内容。
<proxies>

<proxy>

<id>optional</id>

<active>true</active>

<protocol>http</protocol>

<username>proxyuser</username><!--代理的用户名-->

<password>proxypass</password><!--代理的密码-->

<host>proxy.host.net</host><!--代理的主机名-->

<port>80</port><!--代理的端口号-->

<nonProxyHosts>local.net|some.host.com</nonProxyHosts>

</proxy>

</proxies>


2.5 设置镜像

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

<mirrors>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>repo2</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://repo2.maven.org/maven2/</url>
</mirror>
<mirror>
<id>ui</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://uk.maven.org/maven2/</url>
</mirror>
<mirror>
<id>ibiblio</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>
</mirror>
<mirror>
<id>jboss-public-repository-group</id>
<mirrorOf>central</mirrorOf>
<name>JBoss Public Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public</url>
</mirror>
</mirrors>


2.6 设置默认jdk版本

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

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


到这里settings.xml就配置好了。

我的设置如下,大家可以自行修改。

.<?xml version="1.0" encoding="UTF-8"?>
<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\respository</localRepository>
<pluginGroups>
</pluginGroups>
<proxies>
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<host>proxy3.xx.xxxx</host>
<port>8080</port>
<nonProxyHosts>local.net|some.host.com</nonProxyHosts>
</proxy>
</proxies>
<servers>
</servers>
<mirrors> <mirror> <id>alimaven</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> <mirror> <id>repo2</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://repo2.maven.org/maven2/</url> </mirror> <mirror> <id>ui</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://uk.maven.org/maven2/</url> </mirror> <mirror> <id>ibiblio</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url> </mirror> <mirror> <id>jboss-public-repository-group</id> <mirrorOf>central</mirrorOf> <name>JBoss Public Repository Group</name> <url>http://repository.jboss.org/nexus/content/groups/public</url> </mirror> </mirrors>
<profiles>
<profile> <id>jdk-1.8</id> <activation> <activeByDefault>true</activeByDefault> <jdk>1.8</jdk> </activation> <properties> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.compilerVersion>1.8</maven.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进入编辑页面,设置自己喜欢的字体大小和样式。





然后,设置默认编码为utf-8。还是在preferences对话框中,左边点击General->workspace,右边向下拉,text file encoding选择other utf-8。



3.3 配置maven

在preferences对话框中,选择maven->Installations,在右边点击add



在新弹出的对话框中点击Directory按钮。选择我们解压maven 的路径



选择后Installation name会自动填入值。点击finish。

然后点击Apply and Close



配置maven仓库

在preferences对话框中,选择maven->UserSerttings。在UserSettings中选择maven中修改好的settings.xml文件,然后保存。



到这里开发环境算搭建好了,下面开始测试
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  spring maven