Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="UTF-8"?>
- <beans
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns="http://www.springframework.org/schema/beans"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
- http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd">
- <context:component-scan base-package="ru.milli"/>
- <mvc:annotation-driven/>
- </beans>
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns="http://www.springframework.org/schema/beans"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
- <import resource="classpath:application-context.xml"/>
- </beans>
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:mvc="http://www.springframework.org/schema/mvc"
- xmlns="http://www.springframework.org/schema/beans"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/mvc
- http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd">
- <import resource="classpath:application-context.xml"/>
- <mvc:resources mapping="/resources/**" location="/resources/"/>
- </beans>
- package ru.rusal.mishka.core;
- import com.mchange.v2.c3p0.ComboPooledDataSource;
- import org.eclipse.persistence.jpa.PersistenceProvider;
- import org.springframework.beans.factory.annotation.Qualifier;
- import org.springframework.context.annotation.Bean;
- import org.springframework.context.annotation.Configuration;
- import org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver;
- import org.springframework.orm.jpa.JpaTransactionManager;
- import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
- import javax.persistence.EntityManagerFactory;
- import javax.persistence.ValidationMode;
- import javax.sql.DataSource;
- import java.beans.PropertyVetoException;
- import java.util.Properties;
- @Configuration
- public class ContextConfiguration {
- @Bean
- public DataSource dataSource(
- @Qualifier("systemConfiguration") SystemConfiguration systemConfiguration
- ) throws PropertyVetoException {
- Properties props = new Properties();
- props.setProperty("user", systemConfiguration.getDBConfig().getUser());
- props.setProperty("password", systemConfiguration.getDBConfig().getPassword());
- final ComboPooledDataSource dataSource = new ComboPooledDataSource();
- dataSource.setDriverClass("oracle.jdbc.OracleDriver");
- dataSource.setJdbcUrl("jdbc:oracle:thin:@localhost:1521:DB");
- dataSource.setInitialPoolSize(5);
- dataSource.setMaxPoolSize(20);
- dataSource.setProperties(props);
- return dataSource;
- }
- @Bean
- public LocalContainerEntityManagerFactoryBean entityManagerFactory(
- @Qualifier("dataSource") DataSource ds
- ) {
- LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean();
- factoryBean.setPersistenceUnitName("MilliService");
- factoryBean.setDataSource(ds);
- factoryBean.setPersistenceProviderClass(PersistenceProvider.class);
- factoryBean.setLoadTimeWeaver(new InstrumentationLoadTimeWeaver());
- factoryBean.setValidationMode(ValidationMode.NONE);
- factoryBean.setPackagesToScan("ru.milli.app.persistence");
- factoryBean.getJpaPropertyMap().put("eclipselink.weaving", Boolean.FALSE.toString());
- factoryBean.getJpaPropertyMap().put("eclipselink.allow-zero-id", Boolean.TRUE.toString());
- return factoryBean;
- }
- @Bean
- public JpaTransactionManager transactionManager(
- @Qualifier("entityManagerFactory") EntityManagerFactory factory
- ) throws PropertyVetoException {
- JpaTransactionManager manager = new JpaTransactionManager();
- manager.setEntityManagerFactory(factory);
- return manager;
- }
- }
- <?xml version="1.0" encoding="UTF-8"?>
- <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- version="2.4"
- xmlns="http://java.sun.com/xml/ns/j2ee"
- xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
- http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
- <!-- Display name -->
- <display-name>mishka</display-name>
- <listener>
- <listener-class>ru.milli.CleanupContextListener</listener-class>
- </listener>
- <servlet>
- <servlet-name>webportal</servlet-name>
- <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
- </servlet>
- <servlet>
- <servlet-name>rest</servlet-name>
- <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
- </servlet>
- <servlet-mapping>
- <servlet-name>rest</servlet-name>
- <url-pattern>/rest/*</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
- <servlet-name>webportal</servlet-name>
- <url-pattern>*.html</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
- <servlet-name>webportal</servlet-name>
- <url-pattern>/image.jpeg</url-pattern>
- </servlet-mapping>
- <error-page>
- <error-code>500</error-code>
- <location>/WEB-INF/jsp/error.jsp</location>
- </error-page>
- <error-page>
- <error-code>404</error-code>
- <location>/error.html</location>
- </error-page>
- <welcome-file-list>
- <welcome-file>/WEB-INF/jsp/start.jsp</welcome-file>
- </welcome-file-list>
- <jsp-config>
- <taglib>
- <taglib-uri>http://www.springframework.org/tags</taglib-uri>
- <taglib-location>/WEB-INF/tld/spring.tld</taglib-location>
- </taglib>
- <taglib>
- <taglib-uri>http://www.springframework.org/tags/form</taglib-uri>
- <taglib-location>/WEB-INF/tld/spring-form.tld</taglib-location>
- </taglib>
- </jsp-config>
- </web-app>
Add Comment
Please, Sign In to add comment