forked from ntut-ben/ezfit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
during change to spring mvc framework - first backup
- Loading branch information
Showing
2,106 changed files
with
2,807 additions
and
1,643 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0"> | ||
|
||
<wb-module deploy-name="ezfit-0.0.1-SNAPSHOT"> | ||
|
||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/> | ||
|
||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/> | ||
|
||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/> | ||
|
||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/> | ||
|
||
<property name="context-root" value="ezfit"/> | ||
|
||
<property name="java-output-path" value="/ezfit/target/classes"/> | ||
|
||
</wb-module> | ||
|
||
</project-modules> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package config; | ||
|
||
import java.beans.PropertyVetoException; | ||
import java.util.Properties; | ||
|
||
import javax.sql.DataSource; | ||
|
||
import org.hibernate.SessionFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.orm.hibernate5.HibernateTransactionManager; | ||
import org.springframework.orm.hibernate5.LocalSessionFactoryBean; | ||
import org.springframework.transaction.annotation.EnableTransactionManagement; | ||
|
||
import com.mchange.v2.c3p0.ComboPooledDataSource; | ||
|
||
@Configuration | ||
@EnableTransactionManagement | ||
@ComponentScan({ "shopping.repository", "shopping.service", "createAccount.repository", "createAccount.service", | ||
"login.service" }) | ||
public class RootAppConfig { | ||
|
||
@Bean | ||
public DataSource dataSource() { | ||
ComboPooledDataSource ds = new ComboPooledDataSource(); | ||
ds.setUser("root"); | ||
ds.setPassword("1qaz@WSX"); | ||
try { | ||
ds.setDriverClass("com.mysql.cj.jdbc.Driver"); | ||
} catch (PropertyVetoException e) { | ||
e.printStackTrace(); | ||
} | ||
ds.setJdbcUrl( | ||
"jdbc:mysql://localhost:3306/ezfit?useSSL=false&useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Taipei"); | ||
ds.setInitialPoolSize(4); | ||
ds.setMaxPoolSize(8); | ||
return ds; | ||
} | ||
|
||
@Bean | ||
public LocalSessionFactoryBean sessionFactory() { | ||
LocalSessionFactoryBean factory = new LocalSessionFactoryBean(); | ||
factory.setDataSource(dataSource()); | ||
factory.setPackagesToScan(new String[] { "createAccount.model", "shopping.model", "login.model" }); | ||
factory.setHibernateProperties(additionalProperties()); | ||
return factory; | ||
} | ||
|
||
@Bean(name = "transactionManager") | ||
@Autowired | ||
public HibernateTransactionManager transactionManager(SessionFactory sessionFactory) { | ||
|
||
HibernateTransactionManager txManager = new HibernateTransactionManager(); | ||
txManager.setSessionFactory(sessionFactory); | ||
return txManager; | ||
} | ||
|
||
private Properties additionalProperties() { | ||
Properties properties = new Properties(); | ||
properties.put("hibernate.dialect", org.hibernate.dialect.MySQL8Dialect.class); | ||
properties.put("hibernate.show_sql", Boolean.FALSE); | ||
properties.put("hibernate.format_sql", Boolean.TRUE); | ||
properties.put("default_batch_fetch_size", 10); | ||
properties.put("hibernate.hbm2ddl.auto", "update"); | ||
return properties; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package config; | ||
|
||
import org.springframework.context.MessageSource; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.support.ResourceBundleMessageSource; | ||
import org.springframework.web.servlet.ViewResolver; | ||
import org.springframework.web.servlet.config.annotation.EnableWebMvc; | ||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
import org.springframework.web.servlet.view.InternalResourceViewResolver; | ||
|
||
@Configuration | ||
@EnableWebMvc | ||
@ComponentScan({ "shopping.controller", "home.controller", "createAccount.controller", "login.controller" }) | ||
public class WebAppConfig implements WebMvcConfigurer { | ||
|
||
@Bean | ||
public ViewResolver viewResolver() { | ||
InternalResourceViewResolver internalResourceViewResolver = new InternalResourceViewResolver(); | ||
internalResourceViewResolver.setPrefix("/WEB-INF/views/"); | ||
internalResourceViewResolver.setSuffix(".jsp"); | ||
return internalResourceViewResolver; | ||
} | ||
|
||
@Bean | ||
public MessageSource messageSource() { | ||
ResourceBundleMessageSource resourceBundleMessageSource = new ResourceBundleMessageSource(); | ||
resourceBundleMessageSource.setBasename("messages"); | ||
return resourceBundleMessageSource; | ||
} | ||
|
||
@Override | ||
public void addResourceHandlers(ResourceHandlerRegistry registry) { | ||
registry.addResourceHandler("createAccount/pic/**").addResourceLocations("/WEB-INF/views/createAccount/pic/"); | ||
registry.addResourceHandler("createAccount/js/**").addResourceLocations("/WEB-INF/views/createAccount/js/"); | ||
registry.addResourceHandler("createAccount/css/**").addResourceLocations("/WEB-INF/views/createAccount/css/"); | ||
registry.addResourceHandler("login/**").addResourceLocations("/WEB-INF/views/login/"); | ||
registry.addResourceHandler("index/img/**").addResourceLocations("/WEB-INF/views/index/img/"); | ||
registry.addResourceHandler("index/js/**").addResourceLocations("/WEB-INF/views/index/js/"); | ||
registry.addResourceHandler("index/css/**").addResourceLocations("/WEB-INF/views/index/css/"); | ||
registry.addResourceHandler("/productImage/**").addResourceLocations("/WEB-INF/views/productImage/"); | ||
registry.addResourceHandler("/css/**").addResourceLocations("/WEB-INF/views/css/"); | ||
registry.addResourceHandler("/js/**").addResourceLocations("/WEB-INF/views/js/"); | ||
registry.addResourceHandler("/images/**").addResourceLocations("/WEB-INF/views/images/"); | ||
registry.addResourceHandler("/img/**").addResourceLocations("/WEB-INF/views/img/"); | ||
} | ||
|
||
} |
Oops, something went wrong.