Przeglądaj źródła

Rename ServiceMain=>Application

Chris Beams 13 lat temu
rodzic
commit
5c9477bf75
3 zmienionych plików z 10 dodań i 10 usunięć
  1. 7
    7
      README.md
  2. 1
    1
      complete/pom.xml
  3. 2
    2
      complete/src/main/java/hello/Application.java

+ 7
- 7
README.md Wyświetl plik

203
 
203
 
204
 ### Create a main class
204
 ### Create a main class
205
 
205
 
206
-`src/main/java/hello/ServiceMain.java`
206
+`src/main/java/hello/Application.java`
207
 
207
 
208
 ```java
208
 ```java
209
 package hello;
209
 package hello;
214
 
214
 
215
 @ComponentScan
215
 @ComponentScan
216
 @EnableAutoConfiguration
216
 @EnableAutoConfiguration
217
-public class ServiceMain {
217
+public class Application {
218
 
218
 
219
     public static void main(String[] args) {
219
     public static void main(String[] args) {
220
-        SpringApplication.run(ServiceMain.class, args);
220
+        SpringApplication.run(Application.class, args);
221
     }
221
     }
222
 }
222
 }
223
 ```
223
 ```
224
-The `main()` method defers to the [`SpringApplication`][] helper class, providing `ServiceMain.class` as an argument to its `run()` method. This tells Spring to read the annotation metadata from `ServiceMain` and to manage it as a component in the _[Spring application context][u-application-context]_.
224
+The `main()` method defers to the [`SpringApplication`][] helper class, providing `Application.class` as an argument to its `run()` method. This tells Spring to read the annotation metadata from `Application` and to manage it as a component in the _[Spring application context][u-application-context]_.
225
 
225
 
226
 The `@ComponentScan` annotation tells Spring to recursively search through the `hello` package and its children for classes marked directly or indirectly with Spring's [`@Component`][] annotation. This directive ensures that Spring will find and register our `GreetingController`, because it is marked with `@Controller`, which in turn is a kind of `@Component` annotation.
226
 The `@ComponentScan` annotation tells Spring to recursively search through the `hello` package and its children for classes marked directly or indirectly with Spring's [`@Component`][] annotation. This directive ensures that Spring will find and register our `GreetingController`, because it is marked with `@Controller`, which in turn is a kind of `@Component` annotation.
227
 
227
 
229
 
229
 
230
 ### Build an executable JAR
230
 ### Build an executable JAR
231
 
231
 
232
-Now that we have our `ServiceMain` class ready to go, we simply need to instruct the build system to create a single, executable jar containing everything. This will make it dead simple to ship and version and deploy the service as an application throughout the development lifecycle, across different environments, etc.
232
+Now that we have our `Application` class ready to go, we simply need to instruct the build system to create a single, executable jar containing everything. This will make it dead simple to ship and version and deploy the service as an application throughout the development lifecycle, across different environments, etc.
233
 
233
 
234
 Add the following configuration to your existing Maven POM
234
 Add the following configuration to your existing Maven POM
235
 
235
 
236
 `pom.xml`
236
 `pom.xml`
237
 ```xml
237
 ```xml
238
     <properties>
238
     <properties>
239
-        <start-class>hello.ServiceMain</start-class>
239
+        <start-class>hello.Application</start-class>
240
     </properties>
240
     </properties>
241
 
241
 
242
     <build>
242
     <build>
249
     </build>
249
     </build>
250
 ```
250
 ```
251
 
251
 
252
-The `start-class` property tells Maven to create a `META-INF/MANIFEST.MF` file with a `Main-Class: hello.ServiceMain` entry. This is the key to being able to run the jar with `java -jar`.
252
+The `start-class` property tells Maven to create a `META-INF/MANIFEST.MF` file with a `Main-Class: hello.Application` entry. This is the key to being able to run the jar with `java -jar`.
253
 
253
 
254
 The [Maven Shade plugin][maven-shade-plugin] extracts classes from all the jars on the classpath and builds a single "über-jar". This makes it much more convenient to execute and transport your service.
254
 The [Maven Shade plugin][maven-shade-plugin] extracts classes from all the jars on the classpath and builds a single "über-jar". This makes it much more convenient to execute and transport your service.
255
 
255
 

+ 1
- 1
complete/pom.xml Wyświetl plik

25
     </dependencies>
25
     </dependencies>
26
 
26
 
27
     <properties>
27
     <properties>
28
-        <start-class>hello.ServiceMain</start-class>
28
+        <start-class>hello.Application</start-class>
29
     </properties>
29
     </properties>
30
 
30
 
31
     <build>
31
     <build>

complete/src/main/java/hello/ServiceMain.java → complete/src/main/java/hello/Application.java Wyświetl plik

6
 
6
 
7
 @ComponentScan
7
 @ComponentScan
8
 @EnableAutoConfiguration
8
 @EnableAutoConfiguration
9
-public class ServiceMain {
9
+public class Application {
10
 
10
 
11
     public static void main(String[] args) {
11
     public static void main(String[] args) {
12
-        SpringApplication.run(ServiceMain.class, args);
12
+        SpringApplication.run(Application.class, args);
13
     }
13
     }
14
 }
14
 }