commit 1dfa28f70c498561a59476ea6343185728555647 Author: geek Date: Wed Mar 23 14:09:27 2016 +0900 Re Shared diff --git a/maven_archetype_spring_webapp.iml b/maven_archetype_spring_webapp.iml new file mode 100644 index 0000000..eb2ad25 --- /dev/null +++ b/maven_archetype_spring_webapp.iml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..b6760e6 --- /dev/null +++ b/pom.xml @@ -0,0 +1,48 @@ + + + + com.loafle + maven_parent_jar + 1.0.0-RELEASES + + + 4.0.0 + + com.loafle + maven_archetype_spring_webapp + 4.2.0-RELEASES + maven_archetype_spring_webapp + maven-archetype + + + + + org.apache.maven.archetype + archetype-packaging + 2.4 + + + + + + + org.apache.maven.plugins + maven-archetype-plugin + 2.4 + true + + + org.apache.maven.plugins + maven-resources-plugin + 2.4 + + true + + + + + + + \ No newline at end of file diff --git a/src/main/resources/META-INF/maven/archetype-metadata.xml b/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 0000000..1d2d394 --- /dev/null +++ b/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,29 @@ + + + + + src/main/java + + **/*.java + + + + src/main/resources + + + src/main/webapp + + + src/test/java + + **/*.java + + + + src/test/resources + + + diff --git a/src/main/resources/archetype-resources/pom.xml b/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 0000000..a4e44e7 --- /dev/null +++ b/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,146 @@ + + + + + com.loafle + maven_parent_spring + 4.2.0-RELEASES + + + 4.0.0 + + ${groupId} + ${artifactId} + war + ${version} + Untitle + + + UTF-8 + + + + + + 3.1.0 + 4.0.3.RELEASE + 5.0.6.Final + 2.5.0 + + + + + org.springframework.data + spring-data-jpa + 1.9.2.RELEASE + + + + + org.springframework.security + spring-security-web + ${springsecurity.version} + + + org.springframework.security + spring-security-config + ${springsecurity.version} + + + org.springframework.security + spring-security-aspects + ${springsecurity.version} + + + org.springframework.security + spring-security-messaging + ${springsecurity.version} + + + + + org.springframework + spring-websocket + ${springframework.version} + + + org.springframework + spring-messaging + ${springframework.version} + + + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + com.fasterxml.jackson.core + jackson-core + ${jackson.version} + + + com.fasterxml.jackson.core + jackson-annotations + ${jackson.version} + + + + + org.thymeleaf + thymeleaf-spring4 + 2.1.4.RELEASE + + + javassist + org.javassist + + + + + org.thymeleaf.extras + thymeleaf-extras-springsecurity4 + 2.1.2.RELEASE + + + nz.net.ultraq.thymeleaf + thymeleaf-layout-dialect + 1.3.1 + + + + + javax.servlet + javax.servlet-api + ${javax.servlet.version} + provided + + + + org.hibernate + hibernate-entitymanager + ${hibernate.version} + + + org.hibernate + hibernate-validator + 5.2.2.Final + + + + javax.transaction + jta + 1.1 + + + + javax.el + el-api + 2.2 + + + + \ No newline at end of file diff --git a/src/main/resources/archetype-resources/src/main/java/config/WebAppInitializer.java b/src/main/resources/archetype-resources/src/main/java/config/WebAppInitializer.java new file mode 100644 index 0000000..47dd25e --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/java/config/WebAppInitializer.java @@ -0,0 +1,28 @@ +package ${package}.config; + +import org.springframework.web.filter.CharacterEncodingFilter; +import org.springframework.web.filter.DelegatingFilterProxy; +import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; + +import javax.servlet.Filter; + +/** + * Created by geek on 2016-01-25. + */ +public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { + + @Override + protected Class[] getRootConfigClasses() { + return new Class[0]; + } + + @Override + protected Class[] getServletConfigClasses() { + return new Class[0]; + } + + @Override + protected String[] getServletMappings() { + return new String[0]; + } +} diff --git a/src/main/resources/archetype-resources/src/main/resources/logback.xml b/src/main/resources/archetype-resources/src/main/resources/logback.xml new file mode 100644 index 0000000..e1df174 --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/resources/logback.xml @@ -0,0 +1,17 @@ + + + ${artifactId} + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{32} - %msg%n + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/archetype-resources/src/main/resources/persistence.properties b/src/main/resources/archetype-resources/src/main/resources/persistence.properties new file mode 100644 index 0000000..a6617a5 --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/resources/persistence.properties @@ -0,0 +1,7 @@ +db.driver= +db.url= +db.username= +db.password= + +hibernate.dialect= +hibernate.hbm2ddl.auto=update \ No newline at end of file diff --git a/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/views/_ b/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/views/_ new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml b/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..9f88c1f --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,7 @@ + + + + Archetype Created Web Application + diff --git a/src/main/resources/archetype-resources/src/main/webapp/index.html b/src/main/resources/archetype-resources/src/main/webapp/index.html new file mode 100644 index 0000000..15df316 --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/webapp/index.html @@ -0,0 +1,10 @@ + + + + + Hello World! + + +Hello World! + + \ No newline at end of file diff --git a/src/main/resources/archetype-resources/src/main/webapp/index.jsp b/src/main/resources/archetype-resources/src/main/webapp/index.jsp new file mode 100644 index 0000000..c38169b --- /dev/null +++ b/src/main/resources/archetype-resources/src/main/webapp/index.jsp @@ -0,0 +1,5 @@ + + +

Hello World!

+ + diff --git a/src/main/resources/archetype-resources/src/main/webapp/resources/fonts/_ b/src/main/resources/archetype-resources/src/main/webapp/resources/fonts/_ new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/archetype-resources/src/main/webapp/resources/images/_ b/src/main/resources/archetype-resources/src/main/webapp/resources/images/_ new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/archetype-resources/src/main/webapp/resources/javascript/_ b/src/main/resources/archetype-resources/src/main/webapp/resources/javascript/_ new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/archetype-resources/src/main/webapp/resources/styles/_ b/src/main/resources/archetype-resources/src/main/webapp/resources/styles/_ new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/archetype-resources/src/main/webapp/resources/third-party/_ b/src/main/resources/archetype-resources/src/main/webapp/resources/third-party/_ new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/archetype-resources/src/test/java/config/PersitenceConfigurationTest.java b/src/main/resources/archetype-resources/src/test/java/config/PersitenceConfigurationTest.java new file mode 100644 index 0000000..4ca47a2 --- /dev/null +++ b/src/main/resources/archetype-resources/src/test/java/config/PersitenceConfigurationTest.java @@ -0,0 +1,94 @@ +package $ + +import javax.sql.DataSource; + +{package}.config; + +import org.hibernate.cfg.Environment; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.ClassPathResource; +import org.springframework.data.jpa.convert.threeten.Jsr310JpaConverters; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.jdbc.datasource.DriverManagerDataSource; +import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; +import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.annotation.EnableTransactionManagement; +import org.springframework.transaction.annotation.TransactionManagementConfigurer; +import org.springframework.util.ClassUtils; + +import javax.sql.DataSource; +import java.util.Properties; + +import javax.inject.Inject; + +import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppContextSetup; + +@Configuration +@EnableTransactionManagement +//@EnableJpaRepositories(basePackageClasses = ServiceMarker.class) +public abstract class PersitenceConfigurationTest implements TransactionManagementConfigurer { + + @Value("${db.driver}") + private String driver; + @Value("${db.url}") + private String url; + @Value("${db.username}") + private String username; + @Value("${db.password}") + private String password; + @Value("${hibernate.dialect}") + private String dialect; + @Value("${hibernate.hbm2ddl.auto}") + private String hbm2ddlAuto; + + @Bean + public static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() { + PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer(); + ppc.setLocation(new ClassPathResource("/persistence.properties")); + ppc.setIgnoreUnresolvablePlaceholders(true); + + return ppc; + } + + @Bean + public DataSource configureDataSource() { + DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName(driver); + dataSource.setUrl(url); + dataSource.setUsername(username); + dataSource.setPassword(password); + return dataSource; + } + + @Bean + public LocalContainerEntityManagerFactoryBean entityManagerFactory() { + String entities = ClassUtils.getPackageName(ServiceMarker.class); + String converters = ClassUtils.getPackageName(Jsr310JpaConverters.class); + + LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean(); + entityManagerFactoryBean.setDataSource(configureDataSource()); + entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter()); + entityManagerFactoryBean.setPackagesToScan(entities, converters); + + Properties jpaProperties = new Properties(); + jpaProperties.put(Environment.DIALECT, dialect); + jpaProperties.put(Environment.HBM2DDL_AUTO, hbm2ddlAuto); + jpaProperties.put(Environment.SHOW_SQL, true); + jpaProperties.put(Environment.USE_GET_GENERATED_KEYS,true); + jpaProperties.put("hibernate.temp.use_jdbc_metadata_defaults",false); + entityManagerFactoryBean.setJpaProperties(jpaProperties); + + return entityManagerFactoryBean; + } + + @Override + @Bean(name = "transactionManager") + public PlatformTransactionManager annotationDrivenTransactionManager() { + return new JpaTransactionManager(); + } +} diff --git a/src/main/resources/archetype-resources/src/test/resources/logback.xml b/src/main/resources/archetype-resources/src/test/resources/logback.xml new file mode 100644 index 0000000..e1df174 --- /dev/null +++ b/src/main/resources/archetype-resources/src/test/resources/logback.xml @@ -0,0 +1,17 @@ + + + ${artifactId} + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{32} - %msg%n + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/archetype-resources/src/test/resources/persistence.properties b/src/main/resources/archetype-resources/src/test/resources/persistence.properties new file mode 100644 index 0000000..a6617a5 --- /dev/null +++ b/src/main/resources/archetype-resources/src/test/resources/persistence.properties @@ -0,0 +1,7 @@ +db.driver= +db.url= +db.username= +db.password= + +hibernate.dialect= +hibernate.hbm2ddl.auto=update \ No newline at end of file