Quellcode durchsuchen

Rename ServiceMain=>Application

Chris Beams vor 13 Jahren
Ursprung
Commit
5c9477bf75
3 geänderte Dateien mit 10 neuen und 10 gelöschten Zeilen
  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 Datei anzeigen

@@ -203,7 +203,7 @@ While it is possible to package this service up as a traditional _web applicatio
203 203
 
204 204
 ### Create a main class
205 205
 
206
-`src/main/java/hello/ServiceMain.java`
206
+`src/main/java/hello/Application.java`
207 207
 
208 208
 ```java
209 209
 package hello;
@@ -214,14 +214,14 @@ import org.springframework.context.annotation.ComponentScan;
214 214
 
215 215
 @ComponentScan
216 216
 @EnableAutoConfiguration
217
-public class ServiceMain {
217
+public class Application {
218 218
 
219 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 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,14 +229,14 @@ The [`@EnableAutoConfiguration`][] annotation has also been added: it switches o
229 229
 
230 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 234
 Add the following configuration to your existing Maven POM
235 235
 
236 236
 `pom.xml`
237 237
 ```xml
238 238
     <properties>
239
-        <start-class>hello.ServiceMain</start-class>
239
+        <start-class>hello.Application</start-class>
240 240
     </properties>
241 241
 
242 242
     <build>
@@ -249,7 +249,7 @@ Add the following configuration to your existing Maven POM
249 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 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 Datei anzeigen

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

complete/src/main/java/hello/ServiceMain.java → complete/src/main/java/hello/Application.java Datei anzeigen

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