Configuring and Importing Sample Projects
Background
Obtain the Kafka development sample project and import the project to IntelliJ IDEA to learn the sample project and develop applications.
Prerequisites
- Ensure that the difference between the local environment time and the cluster time is less than 5 minutes. If the time difference cannot be determined, contact the system administrator. You can view the time of the cluster in the lower-right corner on FusionInsight Manager.
- You have prepared the development environment and MRS cluster configuration files. For details, see Preparing the Configuration Files for Connecting to the Cluster.
Procedure
- Obtain the sample project folder.
Obtain the sample project folder kafka-examples in the src directory where the sample code is decompressed. For details, see Obtaining the MRS Application Development Sample Project.
- Obtain configuration files.
If the Kafka sample code needs to be commissioned on the local Windows PC, place keytab files user.keytab and krb5.conf obtained in Preparing User Information for Cluster Authentication and all configuration files obtained in Preparing the Configuration Files of the Running Environment in the kafka-examples\src\main\resources directory of the sample project.
- Configure the JDK in IntelliJ IDEA after the IntelliJ IDEA and JDK tools are installed.
The operation procedure may vary according to the IDEA version.
- Start IntelliJ IDEA and choose Configure.
Figure 1 Quick Start
- Choose Project Defaults > Project Structure from the drop-down list box.
Figure 2 Configure
- On the displayed Project Structure for New Projects page, select SDKs, click the plus sign (+), and click JDK.
Figure 3 Project Structure for New Projects
- On the Select Home Directory for JDK page that is displayed, select the JDK directory and click OK.
Figure 4 Select Home Directory for JDK
- After selecting the JDK, click OK to complete the configuration.
Figure 5 Completing the JDK configuration
- Start IntelliJ IDEA and choose Configure.
- Import the sample project to the IntelliJ IDEA development environment.
- Start IntelliJ IDEA and choose Open.
The Browse Folder dialog box is displayed.
- Select a sample project folder, and click OK.
- After the import is complete, check that the imported sample projects are displayed on the IDEA home page.
- Right-click pom.xml and choose Add as Maven Project from the shortcut menu to add the project as a Maven project. If the "pom.xml" icon is displayed as , go to the next step.
Figure 6 Add as Maven Project
- Start IntelliJ IDEA and choose Open.
- Set the Maven version used by the project.
- Choose File > Settings... from the main menu of IntelliJ IDEA.
Figure 7 Settings
- Choose Build, Execution, Deployment > Maven and set Maven home directory to the Maven version installed on the local PC.
Set User settings file and Local repository as you need, and click Apply > OK.Figure 8 Selecting the local Maven installation directory
- Choose File > Settings... from the main menu of IntelliJ IDEA.
- Set the IntelliJ IDEA text file coding format to prevent garbled characters.
- On the IntelliJ IDEA menu bar, choose File > Settings.
The Settings window is displayed.
- In the left navigation pane, choose Editor > File Encodings. In the Project Encoding and Global Encoding areas, set the parameter to UTF-8. Click Apply and OK, as shown in Figure 9.
- On the IntelliJ IDEA menu bar, choose File > Settings.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot