mirror of
https://gitee.com/dcren/initializr.git
synced 2025-04-05 17:38:06 +08:00
Migrate application to Maven
This commit migrates the `initializr-service` to a regular Maven project. Closes gh-252
This commit is contained in:
parent
98a1049cec
commit
1fd8e2c047
8
.gitignore
vendored
8
.gitignore
vendored
@ -13,12 +13,4 @@ build
|
|||||||
target
|
target
|
||||||
.springBeans
|
.springBeans
|
||||||
tmp*
|
tmp*
|
||||||
initializer-service/spring
|
|
||||||
grapes
|
grapes
|
||||||
spring.zip
|
|
||||||
repository/
|
|
||||||
*.jar
|
|
||||||
*.jar.orig
|
|
||||||
*.jar.original
|
|
||||||
.idea
|
|
||||||
*.iml
|
|
||||||
|
66
README.adoc
66
README.adoc
@ -31,6 +31,10 @@ many environments (including embedded in your own project)
|
|||||||
* `initializr-actuator`: optional module to provide statistics and metrics on project
|
* `initializr-actuator`: optional module to provide statistics and metrics on project
|
||||||
generation
|
generation
|
||||||
|
|
||||||
|
`initializr-service` is an additional module that represents the production instance that
|
||||||
|
is available at link:https://start.spring.io[]. It is not enabled by default but you can
|
||||||
|
enable the `full` profile in your IDE to easily run it locally.
|
||||||
|
|
||||||
== Supported interfaces
|
== Supported interfaces
|
||||||
|
|
||||||
Spring Initializr can be used as follows:
|
Spring Initializr can be used as follows:
|
||||||
@ -91,7 +95,7 @@ $ curl https://start.spring.io/starter.tgz -d dependencies=web,actuator \
|
|||||||
-d language=groovy -d type=gradle-project -d baseDir=another-project | tar -xzvf -
|
-d language=groovy -d type=gradle-project -d baseDir=another-project | tar -xzvf -
|
||||||
----
|
----
|
||||||
|
|
||||||
NOTE: The `/starter.tgz` endpoint offers the same feature as `/starter.zip` but generates
|
NOTE: The `/starter.tgz` endpoint offers the same feature as `/starter.zip` but generates
|
||||||
a compressed tarball instead.
|
a compressed tarball instead.
|
||||||
|
|
||||||
You could use this infrastructure to create your own client since the project is generated
|
You could use this infrastructure to create your own client since the project is generated
|
||||||
@ -177,43 +181,7 @@ You may also want to <<run-app,run the default instance locally>>.
|
|||||||
[[build]]
|
[[build]]
|
||||||
== Building from Source
|
== Building from Source
|
||||||
|
|
||||||
You need Java (1.6 or better) and a bash-like shell.
|
You need Java (1.7 or better), Maven 3.2+ and a bash-like shell.
|
||||||
|
|
||||||
If you are on a Mac and using http://brew.sh/[homebrew], all you need to do to install it is:
|
|
||||||
|
|
||||||
[indent=0]
|
|
||||||
----
|
|
||||||
$ brew tap pivotal/tap
|
|
||||||
$ brew install springboot
|
|
||||||
----
|
|
||||||
|
|
||||||
It will install `/usr/local/bin/spring`. You can jump right to <<run-app>>.
|
|
||||||
|
|
||||||
An alternative way to install the `spring` command line interface can be installed like this:
|
|
||||||
|
|
||||||
[indent=0]
|
|
||||||
----
|
|
||||||
$ curl start.spring.io/install.sh | bash
|
|
||||||
----
|
|
||||||
|
|
||||||
After running that command you should see a `spring` directory:
|
|
||||||
|
|
||||||
[indent=0]
|
|
||||||
----
|
|
||||||
$ ./spring/bin/spring --help
|
|
||||||
|
|
||||||
usage: spring [--help] [--version]
|
|
||||||
<command> [<args>]
|
|
||||||
...
|
|
||||||
----
|
|
||||||
|
|
||||||
You could add that `bin` directory to your `PATH` (the examples below
|
|
||||||
assume you did that).
|
|
||||||
|
|
||||||
If you don't have `curl` or `zip` you can probably get them (for
|
|
||||||
Windows users we recommend http://cygwin.org[cygwin]), or you can
|
|
||||||
download the http://start.spring.io/spring.zip[zip file] and unpack
|
|
||||||
it yourself.
|
|
||||||
|
|
||||||
[[building]]
|
[[building]]
|
||||||
=== Building
|
=== Building
|
||||||
@ -237,13 +205,13 @@ If you want to run the smoke tests using Geb, you need to enable the
|
|||||||
[[run-app]]
|
[[run-app]]
|
||||||
=== Running the app locally
|
=== Running the app locally
|
||||||
|
|
||||||
Once you have <<building, built the library>>, you can easily start the app using the `spring` command
|
Once you have <<building, built the library>>, you can easily start the app as any other
|
||||||
from the `initializr-service` directory:
|
Spring Boot app from the `initializr-service` directory:
|
||||||
|
|
||||||
[indent=0]
|
[indent=0]
|
||||||
----
|
----
|
||||||
$ cd initializr-service
|
$ cd initializr-service
|
||||||
$ spring run app.groovy
|
$ mvn spring-boot:run
|
||||||
----
|
----
|
||||||
|
|
||||||
## Deploying to Cloud Foundry
|
## Deploying to Cloud Foundry
|
||||||
@ -258,29 +226,23 @@ If you are on a Mac and using http://brew.sh/[homebrew], install the Cloud Found
|
|||||||
Alternatively, download a suitable binary for your platform from
|
Alternatively, download a suitable binary for your platform from
|
||||||
https://console.run.pivotal.io/tools[Pivotal Web Services].
|
https://console.run.pivotal.io/tools[Pivotal Web Services].
|
||||||
|
|
||||||
An example Cloud Foundry `manifest.yml` file is provided. You should ensure that
|
You should ensure that the application name and URL (name and host values) are suitable for
|
||||||
the application name and URL (name and host values) are suitable for your environment
|
your environment before running `cf push`.
|
||||||
before running `cf push`.
|
|
||||||
|
|
||||||
You can jar up the app and make it executable in any environment.
|
Make sure first that the jar has been created:
|
||||||
|
|
||||||
[indent=0]
|
[indent=0]
|
||||||
----
|
----
|
||||||
$ spring jar start.jar app.groovy
|
$ mvn package
|
||||||
----
|
----
|
||||||
|
|
||||||
Once the jar has been created, you can push the application:
|
Once the jar has been created, you can push the application:
|
||||||
|
|
||||||
[indent=0]
|
[indent=0]
|
||||||
----
|
----
|
||||||
$ cf push start -p start.jar -n start-<space>
|
$ cf push your-initializr -p target/initializr-service-1.0.0.BUILD-SNAPSHOT
|
||||||
----
|
----
|
||||||
|
|
||||||
Where `<space>` is the name of the space. As a failsafe, and a
|
|
||||||
reminder to be explicit, the deployment will fail in production
|
|
||||||
without the `-n`. It is needed to select the route because there is a
|
|
||||||
manifest that defaults it to `start-development`.
|
|
||||||
|
|
||||||
== License
|
== License
|
||||||
Spring Initializr is Open Source software released under the
|
Spring Initializr is Open Source software released under the
|
||||||
http://www.apache.org/licenses/LICENSE-2.0.html[Apache 2.0 license].
|
http://www.apache.org/licenses/LICENSE-2.0.html[Apache 2.0 license].
|
@ -1,39 +0,0 @@
|
|||||||
package app
|
|
||||||
|
|
||||||
import java.util.concurrent.Executor
|
|
||||||
|
|
||||||
import org.springframework.context.annotation.Configuration
|
|
||||||
import org.springframework.scheduling.annotation.AsyncConfigurerSupport
|
|
||||||
import org.springframework.scheduling.annotation.EnableAsync
|
|
||||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
|
|
||||||
|
|
||||||
import io.spring.initializr.web.project.LegacyStsController
|
|
||||||
|
|
||||||
@Grab('io.spring.initializr:initializr-actuator:1.0.0.BUILD-SNAPSHOT')
|
|
||||||
@Grab('io.spring.initializr:initializr-web:1.0.0.BUILD-SNAPSHOT')
|
|
||||||
@Grab('spring-boot-starter-web')
|
|
||||||
@Grab('spring-boot-starter-redis')
|
|
||||||
class InitializerService {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
LegacyStsController legacyStsController() {
|
|
||||||
new LegacyStsController()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@EnableAsync
|
|
||||||
static class AsyncConfiguration extends AsyncConfigurerSupport {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
Executor getAsyncExecutor() {
|
|
||||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor()
|
|
||||||
executor.setCorePoolSize(1)
|
|
||||||
executor.setMaxPoolSize(5)
|
|
||||||
executor.setThreadNamePrefix("initializr-")
|
|
||||||
executor.initialize()
|
|
||||||
executor
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<configuration>
|
|
||||||
|
|
||||||
<include resource="org/springframework/boot/logging/logback/base.xml"/>
|
|
||||||
|
|
||||||
<!--logger name="org.springframework" level="DEBUG"/-->
|
|
||||||
<logger name="org.springframework.core.env" level="WARN"/>
|
|
||||||
<logger name="org.springframework.jndi" level="WARN"/>
|
|
||||||
|
|
||||||
</configuration>
|
|
@ -1,7 +0,0 @@
|
|||||||
---
|
|
||||||
applications:
|
|
||||||
- name: start
|
|
||||||
memory: 1024M
|
|
||||||
host: start-development
|
|
||||||
domain: cfapps.io
|
|
||||||
path: .
|
|
49
initializr-service/pom.xml
Normal file
49
initializr-service/pom.xml
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>io.spring.initializr</groupId>
|
||||||
|
<artifactId>initializr</artifactId>
|
||||||
|
<version>1.0.0.BUILD-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<artifactId>initializr-service</artifactId>
|
||||||
|
<name>Spring Initializr :: Service</name>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.spring.initializr</groupId>
|
||||||
|
<artifactId>initializr-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.spring.initializr</groupId>
|
||||||
|
<artifactId>initializr-actuator</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.gmavenplus</groupId>
|
||||||
|
<artifactId>gmavenplus-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2016 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.spring.initializr.service
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor
|
||||||
|
|
||||||
|
import io.spring.initializr.web.project.LegacyStsController
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication
|
||||||
|
import org.springframework.context.annotation.Bean
|
||||||
|
import org.springframework.context.annotation.Configuration
|
||||||
|
import org.springframework.scheduling.annotation.AsyncConfigurerSupport
|
||||||
|
import org.springframework.scheduling.annotation.EnableAsync
|
||||||
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializr service application. Enables legacy STS support for older
|
||||||
|
* clients.
|
||||||
|
*
|
||||||
|
* @author Stephane Nicoll
|
||||||
|
* @since 1.0
|
||||||
|
*/
|
||||||
|
@SpringBootApplication
|
||||||
|
class InitializrService {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(InitializrService, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
LegacyStsController legacyStsController() {
|
||||||
|
new LegacyStsController()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableAsync
|
||||||
|
static class AsyncConfiguration extends AsyncConfigurerSupport {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
Executor getAsyncExecutor() {
|
||||||
|
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor()
|
||||||
|
executor.setCorePoolSize(1)
|
||||||
|
executor.setMaxPoolSize(5)
|
||||||
|
executor.setThreadNamePrefix("initializr-")
|
||||||
|
executor.initialize()
|
||||||
|
executor
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -6,6 +6,11 @@ info:
|
|||||||
spring-boot:
|
spring-boot:
|
||||||
version: 1.3.6.RELEASE
|
version: 1.3.6.RELEASE
|
||||||
|
|
||||||
|
logging:
|
||||||
|
level:
|
||||||
|
org.springframework.core.env: warn
|
||||||
|
org.springframework.jndi: warn
|
||||||
|
|
||||||
server:
|
server:
|
||||||
compression:
|
compression:
|
||||||
enabled: true
|
enabled: true
|
Loading…
Reference in New Issue
Block a user