Skip to content

Commit a889ff7

Browse files
committed
[fit] 增加nacos的使用example以及一些类的注释
1 parent 35c9cea commit a889ff7

17 files changed

Lines changed: 496 additions & 15 deletions

File tree

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>org.fitframework.example</groupId>
7+
<artifactId>assistant-for-complicated</artifactId>
8+
<version>1.0-SNAPSHOT</version>
9+
10+
<properties>
11+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
12+
<java.version>17</java.version>
13+
14+
<!-- FIT version -->
15+
<fit.version>3.6.0-SNAPSHOT</fit.version>
16+
17+
<!-- Maven plugin versions -->
18+
<maven.compiler.version>3.14.0</maven.compiler.version>
19+
</properties>
20+
21+
<dependencies>
22+
<dependency>
23+
<groupId>org.fitframework.example</groupId>
24+
<artifactId>weather-for-complicated</artifactId>
25+
<version>1.0-SNAPSHOT</version>
26+
</dependency>
27+
<dependency>
28+
<groupId>org.fitframework</groupId>
29+
<artifactId>fit-starter</artifactId>
30+
<version>${fit.version}</version>
31+
</dependency>
32+
33+
<!-- FIT plugins -->
34+
<dependency>
35+
<groupId>org.fitframework</groupId>
36+
<artifactId>fit-plugins-starter-web</artifactId>
37+
<version>${fit.version}</version>
38+
</dependency>
39+
40+
<!-- 不在默认插件集合中的插件列表 -->
41+
<dependency>
42+
<groupId>org.fitframework.plugin</groupId>
43+
<artifactId>fit-client-http</artifactId>
44+
<version>${fit.version}</version>
45+
<scope>runtime</scope>
46+
</dependency>
47+
<dependency>
48+
<groupId>org.fitframework.plugin</groupId>
49+
<artifactId>fit-http-client-okhttp</artifactId>
50+
<version>${fit.version}</version>
51+
<scope>runtime</scope>
52+
</dependency>
53+
<dependency>
54+
<groupId>org.fitframework.plugin</groupId>
55+
<artifactId>fit-heartbeat-client</artifactId>
56+
<version>${fit.version}</version>
57+
<scope>runtime</scope>
58+
</dependency>
59+
<dependency>
60+
<groupId>org.fitframework.plugin</groupId>
61+
<artifactId>fit-service-registry</artifactId>
62+
<version>${fit.version}</version>
63+
<scope>runtime</scope>
64+
</dependency>
65+
<dependency>
66+
<groupId>org.fitframework.plugin</groupId>
67+
<artifactId>fit-service-discovery</artifactId>
68+
<version>${fit.version}</version>
69+
<scope>runtime</scope>
70+
</dependency>
71+
<dependency>
72+
<groupId>org.fitframework.plugin</groupId>
73+
<artifactId>fit-service-coordination-locator</artifactId>
74+
<version>${fit.version}</version>
75+
<scope>runtime</scope>
76+
</dependency>
77+
<!-- 注册中心的内nacos版实现 -->
78+
<dependency>
79+
<groupId>org.fitframework.plugin</groupId>
80+
<artifactId>fit-service-coordination-nacos</artifactId>
81+
<version>${fit.version}</version>
82+
<scope>runtime</scope>
83+
</dependency>
84+
85+
</dependencies>
86+
87+
<build>
88+
<plugins>
89+
<plugin>
90+
<groupId>org.apache.maven.plugins</groupId>
91+
<artifactId>maven-compiler-plugin</artifactId>
92+
<version>${maven.compiler.version}</version>
93+
<configuration>
94+
<source>${java.version}</source>
95+
<target>${java.version}</target>
96+
<encoding>${project.build.sourceEncoding}</encoding>
97+
<compilerArgs>
98+
<arg>-parameters</arg>
99+
</compilerArgs>
100+
</configuration>
101+
</plugin>
102+
<plugin>
103+
<groupId>org.fitframework</groupId>
104+
<artifactId>fit-build-maven-plugin</artifactId>
105+
<version>${fit.version}</version>
106+
<executions>
107+
<execution>
108+
<id>package-app</id>
109+
<goals>
110+
<goal>package-app</goal>
111+
</goals>
112+
</execution>
113+
</executions>
114+
</plugin>
115+
</plugins>
116+
</build>
117+
</project>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
3+
* This file is a part of the ModelEngine Project.
4+
* Licensed under the MIT License. See License.txt in the project root for license information.
5+
*--------------------------------------------------------------------------------------------*/
6+
7+
package modelengine.fit.example;
8+
9+
import modelengine.fitframework.annotation.Component;
10+
import modelengine.fitframework.annotation.ScanPackages;
11+
import modelengine.fitframework.runtime.FitStarter;
12+
13+
/**
14+
* 启动类。
15+
*
16+
* @author 董智豪
17+
* @since 2025-06-21
18+
*/
19+
@Component
20+
@ScanPackages("modelengine")
21+
public class AssistantStarter {
22+
public static void main(String[] args) {
23+
FitStarter.start(AssistantStarter.class, args);
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
3+
* This file is a part of the ModelEngine Project.
4+
* Licensed under the MIT License. See License.txt in the project root for license information.
5+
*--------------------------------------------------------------------------------------------*/
6+
7+
package modelengine.fit.example.controller;
8+
9+
import modelengine.fit.example.Weather;
10+
import modelengine.fit.http.annotation.GetMapping;
11+
import modelengine.fitframework.annotation.Component;
12+
import modelengine.fitframework.annotation.Fit;
13+
14+
/**
15+
* 表示助手的控制器。
16+
*
17+
* @author 董智豪
18+
* @since 2025-06-21
19+
*/
20+
@Component
21+
public class AssistantController {
22+
private final Weather weather;
23+
24+
public AssistantController(@Fit Weather weather) {
25+
this.weather = weather;
26+
}
27+
28+
/**
29+
* 获取天气信息。
30+
*
31+
* @return 表示天气信息的 {@link String}。
32+
*/
33+
@GetMapping(path = "/weather")
34+
public String getWeather() {
35+
return this.weather.get();
36+
}
37+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
application:
2+
name: 'assistant'
3+
nacos:
4+
serverAddr: 192.168.123.81:8848
5+
worker:
6+
id: 'assistant'
7+
host: '127.0.0.1'
8+
environment: 'local'
9+
environment-sequence: 'local'
10+
11+
12+
server:
13+
http:
14+
port: 8080
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>org.fitframework.example</groupId>
7+
<artifactId>default-weather-for-complicated</artifactId>
8+
<version>1.0-SNAPSHOT</version>
9+
10+
<properties>
11+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
12+
<java.version>17</java.version>
13+
14+
<!-- FIT version -->
15+
<fit.version>3.6.0-SNAPSHOT</fit.version>
16+
17+
<!-- Maven plugin versions -->
18+
<maven.compiler.version>3.14.0</maven.compiler.version>
19+
</properties>
20+
21+
<dependencies>
22+
<dependency>
23+
<groupId>org.fitframework.example</groupId>
24+
<artifactId>weather-for-complicated</artifactId>
25+
<version>1.0-SNAPSHOT</version>
26+
</dependency>
27+
<dependency>
28+
<groupId>org.fitframework</groupId>
29+
<artifactId>fit-starter</artifactId>
30+
<version>${fit.version}</version>
31+
</dependency>
32+
33+
<!-- FIT plugins -->
34+
<dependency>
35+
<groupId>org.fitframework</groupId>
36+
<artifactId>fit-plugins-starter-web</artifactId>
37+
<version>${fit.version}</version>
38+
</dependency>
39+
40+
<!-- 不在默认插件集合中的插件列表 -->
41+
<dependency>
42+
<groupId>org.fitframework.plugin</groupId>
43+
<artifactId>fit-client-http</artifactId>
44+
<version>${fit.version}</version>
45+
<scope>runtime</scope>
46+
</dependency>
47+
<dependency>
48+
<groupId>org.fitframework.plugin</groupId>
49+
<artifactId>fit-http-client-okhttp</artifactId>
50+
<version>${fit.version}</version>
51+
<scope>runtime</scope>
52+
</dependency>
53+
<dependency>
54+
<groupId>org.fitframework.plugin</groupId>
55+
<artifactId>fit-heartbeat-client</artifactId>
56+
<version>${fit.version}</version>
57+
<scope>runtime</scope>
58+
</dependency>
59+
<dependency>
60+
<groupId>org.fitframework.plugin</groupId>
61+
<artifactId>fit-service-registry</artifactId>
62+
<version>${fit.version}</version>
63+
<scope>runtime</scope>
64+
</dependency>
65+
<dependency>
66+
<groupId>org.fitframework.plugin</groupId>
67+
<artifactId>fit-service-discovery</artifactId>
68+
<version>${fit.version}</version>
69+
<scope>runtime</scope>
70+
</dependency>
71+
<dependency>
72+
<groupId>org.fitframework.plugin</groupId>
73+
<artifactId>fit-service-coordination-locator</artifactId>
74+
<version>${fit.version}</version>
75+
<scope>runtime</scope>
76+
</dependency>
77+
<!-- 注册中心的内nacos版实现 -->
78+
<dependency>
79+
<groupId>org.fitframework.plugin</groupId>
80+
<artifactId>fit-service-coordination-nacos</artifactId>
81+
<version>${fit.version}</version>
82+
<scope>runtime</scope>
83+
</dependency>
84+
</dependencies>
85+
86+
<build>
87+
<plugins>
88+
<plugin>
89+
<groupId>org.apache.maven.plugins</groupId>
90+
<artifactId>maven-compiler-plugin</artifactId>
91+
<version>${maven.compiler.version}</version>
92+
<configuration>
93+
<source>${java.version}</source>
94+
<target>${java.version}</target>
95+
<encoding>${project.build.sourceEncoding}</encoding>
96+
<compilerArgs>
97+
<arg>-parameters</arg>
98+
</compilerArgs>
99+
</configuration>
100+
</plugin>
101+
<plugin>
102+
<groupId>org.fitframework</groupId>
103+
<artifactId>fit-build-maven-plugin</artifactId>
104+
<version>${fit.version}</version>
105+
<executions>
106+
<execution>
107+
<id>package-app</id>
108+
<goals>
109+
<goal>package-app</goal>
110+
</goals>
111+
</execution>
112+
</executions>
113+
</plugin>
114+
</plugins>
115+
</build>
116+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
3+
* This file is a part of the ModelEngine Project.
4+
* Licensed under the MIT License. See License.txt in the project root for license information.
5+
*--------------------------------------------------------------------------------------------*/
6+
7+
package modelengine.fit.example;
8+
9+
import modelengine.fitframework.annotation.Component;
10+
import modelengine.fitframework.annotation.Fitable;
11+
12+
/**
13+
* 表示 {@link Weather} 的默认实现。
14+
*
15+
* @author 董智豪
16+
* @since 2025-06-21
17+
*/
18+
@Component
19+
public class DefaultWeather implements Weather {
20+
@Override
21+
@Fitable(id = "default-weather")
22+
public String get() {
23+
return "Default weather application is working.";
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
3+
* This file is a part of the ModelEngine Project.
4+
* Licensed under the MIT License. See License.txt in the project root for license information.
5+
*--------------------------------------------------------------------------------------------*/
6+
7+
package modelengine.fit.example;
8+
9+
import modelengine.fitframework.annotation.Component;
10+
import modelengine.fitframework.annotation.ScanPackages;
11+
import modelengine.fitframework.runtime.FitStarter;
12+
13+
/**
14+
* 启动类。
15+
*
16+
* @author 董智豪
17+
* @since 2025-06-21
18+
*/
19+
@Component
20+
@ScanPackages("modelengine")
21+
public class DefaultWeatherStarter {
22+
public static void main(String[] args) {
23+
FitStarter.start(DefaultWeatherStarter.class, args);
24+
}
25+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
application:
2+
name: 'default-weather'
3+
4+
worker:
5+
id: 'default-weather'
6+
host: '127.0.0.1'
7+
environment: 'local'
8+
environment-sequence: 'local'
9+
10+
nacos:
11+
serverAddr: 192.168.123.81:8848
12+
13+
server:
14+
http:
15+
port: 8081

0 commit comments

Comments
 (0)