diff --git a/src/main/java/com/monkeyk/sos/SpringOauthServerApplication.java b/src/main/java/com/monkeyk/sos/SpringOauthServerApplication.java new file mode 100644 index 0000000..1a137b0 --- /dev/null +++ b/src/main/java/com/monkeyk/sos/SpringOauthServerApplication.java @@ -0,0 +1,18 @@ +package com.monkeyk.sos; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * 2017-12-05 + * + * @author Shengzhao Li + */ +@SpringBootApplication +public class SpringOauthServerApplication { + + public static void main(String[] args) { + SpringApplication.run(SpringOauthServerApplication.class, args); + } +} diff --git a/src/main/java/com/monkeyk/sos/SpringOauthServerServletInitializer.java b/src/main/java/com/monkeyk/sos/SpringOauthServerServletInitializer.java new file mode 100644 index 0000000..c97cd69 --- /dev/null +++ b/src/main/java/com/monkeyk/sos/SpringOauthServerServletInitializer.java @@ -0,0 +1,31 @@ +package com.monkeyk.sos; + +import com.monkeyk.sos.web.WebUtils; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.support.SpringBootServletInitializer; + +import javax.servlet.ServletContext; +import javax.servlet.ServletException; + +/** + * 2017-12-05 + * + * @author Shengzhao Li + */ +public class SpringOauthServerServletInitializer extends SpringBootServletInitializer { + + + @Override + public void onStartup(ServletContext servletContext) throws ServletException { + super.onStartup(servletContext); + + servletContext.setAttribute("sosVersion", WebUtils.VERSION); + } + + + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { + return application.sources(SpringOauthServerApplication.class); + } + +} diff --git a/src/main/java/com/monkeyk/sos/config/ContextConfigurer.java b/src/main/java/com/monkeyk/sos/config/ContextConfigurer.java index 01f3d6f..910f803 100644 --- a/src/main/java/com/monkeyk/sos/config/ContextConfigurer.java +++ b/src/main/java/com/monkeyk/sos/config/ContextConfigurer.java @@ -23,7 +23,7 @@ import javax.sql.DataSource; */ @Configuration @ComponentScan(basePackages = "com.monkeyk.sos") -@PropertySource(value = {"classpath:spring-oauth-server.properties"}) +//@PropertySource(value = {"classpath:spring-oauth-server.properties"}) @EnableTransactionManagement() public class ContextConfigurer { diff --git a/src/main/java/com/monkeyk/sos/web/WebUtils.java b/src/main/java/com/monkeyk/sos/web/WebUtils.java index e532545..803f165 100644 --- a/src/main/java/com/monkeyk/sos/web/WebUtils.java +++ b/src/main/java/com/monkeyk/sos/web/WebUtils.java @@ -10,6 +10,12 @@ import javax.servlet.http.HttpServletRequest; public abstract class WebUtils { + /** + * Sync by pom.xml + */ + public static final String VERSION = "2.0.0"; + + private static ThreadLocal ipThreadLocal = new ThreadLocal<>(); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..50dbe90 --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1,12 @@ +# +# +spring.application.name=spring-oauth-server +# +# MySQL +##################### +spring.datasource.driver-class-name=com.mysql.jdbc.Driver +spring.datasource.url=jdbc:mysql://localhost:3306/oauth2?autoReconnect=true&autoReconnectForPools=true&useUnicode=true&characterEncoding=utf8 +spring.datasource.data-username=andaily +spring.datasource.data-password=andaily + + diff --git a/src/main/resources/logging.properties b/src/main/resources/logging.properties.old similarity index 100% rename from src/main/resources/logging.properties rename to src/main/resources/logging.properties.old diff --git a/src/main/resources/spring-oauth-server.properties b/src/main/resources/spring-oauth-server.properties.old similarity index 100% rename from src/main/resources/spring-oauth-server.properties rename to src/main/resources/spring-oauth-server.properties.old diff --git a/src/test/java/com/monkeyk/sos/SpringOauthServerApplicationTests.java b/src/test/java/com/monkeyk/sos/SpringOauthServerApplicationTests.java new file mode 100644 index 0000000..f8a94ab --- /dev/null +++ b/src/test/java/com/monkeyk/sos/SpringOauthServerApplicationTests.java @@ -0,0 +1,16 @@ +package com.monkeyk.sos; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class SpringOauthServerApplicationTests { + + @Test + public void contextLoads() { + } + +}