Skip to content

Changes to work with Spring Initializr #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions build_an_executable_jar_with_both.adoc
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
:linkattrs:

You can run the application from the command line with Gradle or Maven. Or you can build a single executable JAR file that contains all the necessary dependencies, classes, and resources, and run that. This makes it easy to ship, version, and deploy the service as an application throughout the development lifecycle, across different environments, and so forth.
You can run the application from the command line with Gradle or Maven. You can also build a single executable JAR file that contains all the necessary dependencies, classes, and resources and run that. Building an executable jar so makes it easy to ship, version, and deploy the service as an application throughout the development lifecycle, across different environments, and so forth.

If you are using Gradle, you can run the application using `./gradlew bootRun`. Or you can build the JAR file using `./gradlew build`. Then you can run the JAR file:
If you use Gradle, you can run the application by using `./gradlew bootRun`. Alternatively, you can build the JAR file by using `./gradlew build` and then run the JAR file, as follows:

====
[subs="attributes", role="has-copy-button"]
....
----
java -jar build/libs/{project_id}-0.1.0.jar
....
----
====

If you are using Maven, you can run the application using `./mvnw spring-boot:run`. Or you can build the JAR file with `./mvnw clean package`. Then you can run the JAR file:
If you use Maven, you can run the application by using `./mvnw spring-boot:run`. Alternatively, you can build the JAR file with `./mvnw clean package` and then run the JAR file, as follows:

====
[subs="attributes", role="has-copy-button"]
....
----
java -jar target/{project_id}-0.1.0.jar
....

NOTE: The procedure above will create a runnable JAR. You can also opt to link:/guides/gs/convert-jar-to-war/[build a classic WAR file] instead.
----
====

NOTE: The steps described here create a runnable JAR. You can also link:/guides/gs/convert-jar-to-war/[build a classic WAR file].
4 changes: 2 additions & 2 deletions how_to_complete_this_guide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ifndef::complete[:complete: /complete]

How to complete this guide
--------------------------
Like most Spring link:/guides[Getting Started guides], you can start from scratch and complete each step, or you can bypass basic setup steps that are already familiar to you. Either way, you end up with working code.
Like most Spring link:/guides[Getting Started guides], you can start from scratch and complete each step or you can bypass basic setup steps that are already familiar to you. Either way, you end up with working code.

To **start from scratch**, move on to <<scratch>>.

Expand All @@ -14,4 +14,4 @@ To **skip the basics**, do the following:
- cd into `{project_id}{initial}`
- Jump ahead to <<initial>>.

**When you're finished**, you can check your results against the code in `{project_id}{complete}`.
**When you finish**, you can check your results against the code in `{project_id}{complete}`.
15 changes: 15 additions & 0 deletions spring-boot-application-new-path.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
`@SpringBootApplication` is a convenience annotation that adds all of the following:

- `@Configuration`: Tags the class as a source of bean definitions for the application
context.
- `@EnableAutoConfiguration`: Tells Spring Boot to start adding beans based on classpath
settings, other beans, and various property settings. For example, if `spring-webmvc` is
on the classpath, this annotation flags the application as a web application and activates
key behaviors, such as setting up a `DispatcherServlet`.
- `@ComponentScan`: Tells Spring to look for other components, configurations, and
services in the `com/example` package, letting it find the controllers.

The `main()` method uses Spring Boot's `SpringApplication.run()` method to launch an
application. Did you notice that there was not a single line of XML? There is no `web.xml`
file, either. This web application is 100% pure Java and you did not have to deal with
configuring any plumbing or infrastructure.
18 changes: 13 additions & 5 deletions spring-boot-application.adoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
`@SpringBootApplication` is a convenience annotation that adds all of the following:

- `@Configuration` tags the class as a source of bean definitions for the application context.
- `@EnableAutoConfiguration` tells Spring Boot to start adding beans based on classpath settings, other beans, and various property settings. For example, if **spring-webmvc** is on the classpath this flags the application as a web application and activates key behaviors such as setting up a `DispatcherServlet`.
- `@ComponentScan` tells Spring to look for other components, configurations, and services in the `hello` package, allowing it to find the controllers.

The `main()` method uses Spring Boot's `SpringApplication.run()` method to launch an application. Did you notice that there wasn't a single line of XML? No **web.xml** file either. This web application is 100% pure Java and you didn't have to deal with configuring any plumbing or infrastructure.
- `@Configuration`: Tags the class as a source of bean definitions for the application
context.
- `@EnableAutoConfiguration`: Tells Spring Boot to start adding beans based on classpath
settings, other beans, and various property settings. For example, if `spring-webmvc` is
on the classpath, this annotation flags the application as a web application and activates
key behaviors, such as setting up a `DispatcherServlet`.
- `@ComponentScan`: Tells Spring to look for other components, configurations, and
services in the `hello` package, letting it find the controllers.

The `main()` method uses Spring Boot's `SpringApplication.run()` method to launch an
application. Did you notice that there was not a single line of XML? There is no `web.xml`
file, either. This web application is 100% pure Java and you did not have to deal with
configuring any plumbing or infrastructure.