It is not recommended to use Eclipse to develop SOFA projects. Using Intellij IDEA to develop projects can achieve better results. You are advised to use JDK8 to create a system.

Note:

  1. You are advised to use SOFABoot for the new project of the primary site. See SOFABoot for a quick start

  2. The new application storage path cannot contain Chinese characters.

Environmental installation

Installed Intellij IDEA

Download Intellij IDEA from the official website of Intellij IDEA and install it. You can choose The Community version. If you are qualified, you can purchase the Ultimate version.

Install SOFA’s Intellij IDEA plug-in

Install SOFA Intellij IDEA plug-in by referring to SOFA Intellij IDEA installation tutorial

New SOFA4 project

Created using the Intellij IDEA plug-in

Click the File menu bar of Intellij IDEA, then choose New -> Project, and then choose New SOFA Project, as shown below (note that in order to see the running effect immediately, Web Project is selected here) :

Fill out maven-related information, see the link for GroupID and ArtifactID naming conventions. Select the project type, here we choose to create a Web project, click Next, select the project name and the project path:

Click Finish and Intellij IDEA will automatically start the import project. At this point, a new SOFA4 project is created.

Currently, new systems default to the new packaging method, no longer have the Assmbely directory, see detailsThe indirect dependence of Sofa Assembly no longer hurts

Created using the MVN directive

If you haven’t configured Maven before, download the Ant Maven configuration file. Download it and rename it settings. XML and place it under ~/.m2/.

The core project

MVN org, apache maven. Plugins: maven archetype - plugin: 2.2 alipay. 1: generate \ -DarchetypeRepository=http://mvn.dev.alipay.net:8080/artifactory/repo \ -DarchetypeGroupId=com.alipay.sofa -DarchetypeArtifactId=sofa-archetype \ -DarchetypeVersion=sofa4-SNAPSHOT \ -Dproject_type=core -D__output_encoding=UTF-8Copy the code

Web project

MVN org, apache maven. Plugins: maven archetype - plugin: 2.2 alipay. 1: generate \ -DarchetypeRepository=http://mvn.dev.alipay.net:8080/artifactory/repo \ -DarchetypeGroupId=com.alipay.sofa -DarchetypeArtifactId=sofa-archetype \ -DarchetypeVersion=sofa4-SNAPSHOT \ -Dproject_type=web -D__output_encoding=UTF-8Copy the code

Rest of engineering

MVN org, apache maven. Plugins: maven archetype - plugin: 2.2 alipay. 1: generate \ -DarchetypeRepository=http://mvn.dev.alipay.net:8080/artifactory/repo \ -DarchetypeGroupId=com.alipay.sofa -DarchetypeArtifactId=sofa-archetype \ -DarchetypeVersion=sofa4-SNAPSHOT \ -Dproject_type=rest -D__output_encoding=UTF-8Copy the code

According to the prompt input module goupId, artifactId and other information can be created in the input project artifactId directory.

If the following information is displayed, the application is successfully created.

[INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 12.565s [INFO] Finished at: 2017-10-25T23:58:48+08:00 [INFO] Final Memory: 17M/222M [INFO] ------------------------------------------------------------------------Copy the code

The SOFA4 project is a standard Maven project. You can import it using the Maven project import function of the IDE:

  • IDEA: select File -> Open -> Pom. XML in the root path of the project

  • In Eclipse: Select File > Import > Existing Maven Projects, select the project root directory, and click OK.

Start the project

After the import is complete, wait for Intellij IDEA to complete the index construction, right-click the project root directory and choose Run SOFA Application, as shown in the following figure:

Wait for application to start the end, if there is no mistake, start the MAC users can access the following link to determine whether to start a successful: http://localhost:7777/sample.htm, Windows users can access the following link to determine whether to start a successful: http://localhost/sample.htm

Note On Windows, please visit:http://localhost/sample.htm

Be careful with arirang acceleration, your project may not start!