关于Eclipse非maven项目迁移到Idea解决方案

关于Eclipse非maven项目迁移到Idea解决方案

idea导入eclipse非maven web项目流程

1.idea默认打开上次打开的项目,设置其为打开初始界面

File ->Settings -> Appearance & Behavior ->System Settings -> Startup/Shutdown 取消勾选 Reopen last project on startup项

关于Eclipse非maven项目迁移到Idea解决方案

2.导入eclipse项目

在主界面open…选中需要导入的项目即可

关于Eclipse非maven项目迁移到Idea解决方案

3.项目配置

1.打开 File Project Structure

关于Eclipse非maven项目迁移到Idea解决方案

2.Project Setting下设置项目的jdk 编译后class文件目录 (Project)

关于Eclipse非maven项目迁移到Idea解决方案

3.Modules编写

关于Eclipse非maven项目迁移到Idea解决方案

3.Libraries jar包导入 (需要导入你项目需要的所有jar,若在不同文件夹下,则进行多次导入)

关于Eclipse非maven项目迁移到Idea解决方案

5.Facetts配置

关于Eclipse非maven项目迁移到Idea解决方案

6.Artifacts配置

关于Eclipse非maven项目迁移到Idea解决方案

7.点击Apply即会进行项目整合
8.变编译方修改
File --> Settings --> Build,Execution,Deployment -->Compiler --> Java Compiler --> Use Compiler – >选择 eclipse 则按照eclipse方式进行编写,若使用javac方式的话,build时会报堆内存不足的异常

关于Eclipse非maven项目迁移到Idea解决方案

4.tomcat配置

######1.选择Edit Configurations
关于Eclipse非maven项目迁移到Idea解决方案

2.添加项目的tomcat 点击添加按钮 --> Tomcat Server --> Local

此处需注意,若屏幕高度过窄的话,可能点击添加按钮后,看不到tomcat,只需向下拉即可看到
关于Eclipse非maven项目迁移到Idea解决方案

3.tomcat配置 只需要配置Server 和Deployment两处即可

server配置
关于Eclipse非maven项目迁移到Idea解决方案

Deployment配置
关于Eclipse非maven项目迁移到Idea解决方案

4.配置结束后的样子

关于Eclipse非maven项目迁移到Idea解决方案

配置结束,到这里即可在idea中运行eclipse项目,下面为运行过程中遇到的一些问题

针对idea输出中文乱码解决

1.编译java出现中文乱码

Settings -> Build,Execution,Deployment -> Compiler -> javaCompiler 下的Additional command line parameters 后填入-encoding utf-8 然后apply

2.项目文件中文乱码

Settings -> Editor -> File Encodings内将Global Encoding ,Project Encoding ,Default encoding for properties files 都设置为UTF-8 (即所有能设置为utf-8的地方都设置为utf-8)

3.idea内解决tomcat输出控制台乱码

在tomcat控制界面中 Server 下的VM options内输入-Dfile.encoding=UTF-8,重启基本能解决编码问题
关于Eclipse非maven项目迁移到Idea解决方案

4.在D:\IntelliJ IDEA 2018.1.4\bin\idea64.exe.vmoptions文件里面末尾位置添加-Dfile.encoding=UTF-8重启idea,即可解决控制台输出中文乱码问题

注 : 我是全部设置完重启idea解决tomcat启动控制台输出中文乱码问题

tomcat设置

1.中文乱码问题 : (idea工具下 : 前端页面传递数据到后端出现中文乱码)

打开D:\Tapache-tomcat-7.0.93\conf\sever.xml进行如下配置:

 <Service name="Catalina">
    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" 
               useBodyEncodingForURI="true"
               IEncoding="utf-8"/>
     即在<Connector>标签内增加编码配置,redirectPort="8443" 		useBodyEncodingForURI="true"  IEncoding="utf-8"
2.idea中tomcat启动报错 : LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[链接地址].StandardContext[/项目名]]

修改tomcat\conf\catalina.properties 中

org.apache.catalina.startup.ContextConfig.jarsToSkip=
为
org.apache.catalina.startup.ContextConfig.jarsToSkip=*.jar
3.idea中启动tomcat报错 : 严重: End event threw exception java.lang.NoSuchMethodException: org.apache.catalina.deploy.WebXml addFilter

在tomcat\conf\context.xml中增加如下标签

<Context>

    <!-- Default set of monitored resources -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>

    <!-- Uncomment this to disable session persistence across Tomcat restarts -->
    <!--
    <Manager pathname="" />
    -->

    <!-- Uncomment this to enable Comet connection tacking (provides events
         on session expiration as well as webapp lifecycle) -->
    <!--
    <Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
    -->
    <!--增加代码-->
    <Loader delegate="true" />

</Context>
4.在tomcat中增加用户名,密码 主要用于tomcat主页面manager app查看tomcat中项目使用 若不增加用户名密码,则不能登录manager app

在tomcat/conf/tomcat-users.xml中增加如下标签

<tomcat-users>
<!--
  NOTE:  By default, no user is included in the "manager-gui" role required
  to operate the "/manager/html" web application.  If you wish to use this app,
  you must define such a user - the username and password are arbitrary. It is
  strongly recommended that you do NOT use one of the users in the commented out
  section below since they are intended for use with the examples web
  application.
-->
<!--
  NOTE:  The sample user and role entries below are intended for use with the
  examples web application. They are wrapped in a comment and thus are ignored
  when reading this file. If you wish to configure these users for use with the
  examples web application, do not forget to remove the <!.. ..> that surrounds
  them. You will also need to set the passwords to something appropriate.
-->
<!--
  <role rolename="tomcat"/>
  <role rolename="role1"/>
  <user username="tomcat" password="<must-be-changed>" roles="tomcat"/>
  <user username="both" password="<must-be-changed>" roles="tomcat,role1"/>
  <user username="role1" password="<must-be-changed>" roles="role1"/>
-->
    <!--增加代码-->
    <user username="用户名" password="密码" roles="manager-gui"/>
</tomcat-users>