Solucionado (ver solução)
Solucionado
(ver solução)
6
respostas

Estou mudando a configuração do spring de código java para xml

business-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    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">

    <!-- Enables scanning for @Service and @Repository annotations -->
    <context:component-scan
        base-package="br.com.netsoft.servico,br.com.netsoft.repositorio" />

    <!-- Import the data source definition -->
    <import resource="datasource-config.xml" />
</beans>

datasource-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
      http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
      http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
      http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd">

    <!-- JPA EntityManagerFactory -->
    <bean id="entityManagerFactory"
        class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="persistenceXmlLocation" value="classpath:META-INF/persistence.xml" />
        <property name="persistenceUnitName" value="nota-fiscal-servico-web" />
        <property name="dataSource" ref="dataSource" />
        <property name="jpaVendorAdapter" ref="jpaVendorAdapter" />
        <property name="jpaDialect" ref="jpaDialect" />
    </bean>

    <bean id="jpaVendorAdapter"
        class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
        <!-- <property name="database" value="MYSQL" /> -->
        <property name="databasePlatform" value="org.hibernate.dialect.PostgreSQLDialect" />
        <property name="showSql" value="true" />
    </bean>

    <bean id="jpaDialect" class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />

    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="entityManagerFactory" />
        <property name="dataSource" ref="dataSource" />
        <property name="jpaDialect" ref="jpaDialect" />
    </bean>

    <tx:annotation-driven transaction-manager="transactionManager" />

    <bean id="dataSource"
        class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="org.postgresql.Driver" />
        <property name="url" value="jdbc:postgresql://localhost:5432/prefeitura" />
        <property name="username" value="postgres" />
        <property name="password" value="63Netsis417" />
    </bean>
</beans>

mvc-core-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
      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">

    <!-- <import resource="classpath:dandelion-datatables.xml" /> -->
    <mvc:annotation-driven />
    <context:component-scan base-package="br.com.netsoft.controller" />
<!--     <mvc:default-servlet-handler /> -->
    <import resource="mvc-view-config.xml" />

</beans>
6 respostas

mvc-view-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">

    <bean id="templateResolver"
        class="org.thymeleaf.templateresolver.ServletContextTemplateResolver">
        <property name="prefix" value="/WEB-INF/views/" />
        <property name="suffix" value=".html" />
        <property name="templateMode" value="HTML5" />
        <!-- Template cache is true by default. Set to false if you want -->
        <!-- templates to be automatically updated when modified. -->
        <property name="cacheable" value="false" />
    </bean>

    <bean id="templateEngine" class="org.thymeleaf.spring4.SpringTemplateEngine">
        <property name="templateResolver" ref="templateResolver" />
        <property name="additionalDialects">
            <set>
                <bean class="com.github.dandelion.thymeleaf.dialect.DandelionDialect" />
                <bean
                    class="com.github.dandelion.datatables.thymeleaf.dialect.DataTablesDialect" />
            </set>
        </property>
    </bean>

    <bean class="org.thymeleaf.spring4.view.ThymeleafViewResolver">
        <property name="templateEngine" ref="templateEngine" />
    </bean>
</beans>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">

    <!-- Spring -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:spring/business-config.xml</param-value>
    </context-param>

    <!-- Creates the Spring Container shared by all Servlets and Filters -->
    <listener>
        <description>Spring Loader</description>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <!-- Spring MVC servlet definition and mapping -->
    <servlet>
        <servlet-name>spring</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:spring/mvc-core-config.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>spring</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

    <!-- Dandelion servlet definition and mapping -->
    <servlet>
        <servlet-name>dandelionServlet</servlet-name>
        <servlet-class>com.github.dandelion.core.web.DandelionServlet</servlet-class>
        <load-on-startup>2</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>dandelionServlet</servlet-name>
        <url-pattern>/dandelion-assets/*</url-pattern>
    </servlet-mapping>

    <!-- Dandelion filter definition and mapping -->
    <filter>
        <filter-name>dandelionFilter</filter-name>
        <filter-class>com.github.dandelion.core.web.DandelionFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>dandelionFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <!-- Dandelion-Datatables filter, used for basic export -->
    <filter>
        <filter-name>datatables</filter-name>
        <filter-class>com.github.dandelion.datatables.core.web.filter.DatatablesFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>datatables</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

<!--     <welcome-file-list> -->
<!--         <welcome-file>index.htm</welcome-file> -->
<!--     </welcome-file-list> -->
</web-app>

persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1"
    xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
    <persistence-unit name="nota-fiscal-servico-web"
        transaction-type="RESOURCE_LOCAL">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <!-- Endereço -->
        <class>br.com.netsoft.model.endereco.BairroEntity</class>
        <class>br.com.netsoft.model.endereco.EstadoEntity</class>
        <class>br.com.netsoft.model.endereco.LogradouroEntity</class>
        <class>br.com.netsoft.model.endereco.MunicipioEntity</class>
        <class>br.com.netsoft.model.endereco.PaisEntity</class>
        <class>br.com.netsoft.model.endereco.TipoLogradouroEntity</class>
        <class>br.com.netsoft.model.endereco.ViewEnderecoCepEntity</class>
        <!-- nota fiscal -->
        <class>br.com.netsoft.model.notafiscal.NotaFiscalAlteracaoNumeroEntity</class>
        <class>br.com.netsoft.model.notafiscal.NotaFiscalArquivoEntity</class>
        <class>br.com.netsoft.model.notafiscal.NotaFiscalConstrucaoCivilEntity</class>
        <class>br.com.netsoft.model.notafiscal.NotaFiscalDadoEntity</class>
        <class>br.com.netsoft.model.notafiscal.NotaFiscalEnderecoEntity</class>
        <class>br.com.netsoft.model.notafiscal.NotaFiscalEntity</class>
        <class>br.com.netsoft.model.notafiscal.NotaFiscalGuiaEntity</class>
        <class>br.com.netsoft.model.notafiscal.NotaFiscalIdentificacaoServicoEntity</class>
        <class>br.com.netsoft.model.notafiscal.NotaFiscalValorEntity</class>
        <!-- notafiscal servico -->
        <class>br.com.netsoft.model.notafiscalservico.CnaeSubCodigoEntity</class>
        <class>br.com.netsoft.model.notafiscalservico.CodigoEntity</class>
        <class>br.com.netsoft.model.notafiscalservico.ConfiguracaoNFSeEntity</class>
        <class>br.com.netsoft.model.notafiscalservico.CreditoEntity</class>
        <class>br.com.netsoft.model.notafiscalservico.DenunciaConversaEntity</class>
        <class>br.com.netsoft.model.notafiscalservico.DenunciaEntity</class>
        <class>br.com.netsoft.model.notafiscalservico.ErroAlertaEntity</class>
        <class>br.com.netsoft.model.notafiscalservico.PerguntaFrequenteEntity</class>
        <class>br.com.netsoft.model.notafiscalservico.PerguntaRespostaFrequenteEntity</class>
        <class>br.com.netsoft.model.notafiscalservico.PerguntaRespostaFrequenteVotacaoEntity</class>
        <class>br.com.netsoft.model.notafiscalservico.PessoaContadorEntity</class>
        <class>br.com.netsoft.model.notafiscalservico.PessoaLiberarCancelarNFSeEntity</class>
        <class>br.com.netsoft.model.notafiscalservico.PorcentagemReterEntity</class>
        <class>br.com.netsoft.model.notafiscalservico.ServicoEntity</class>
        <class>br.com.netsoft.model.notafiscalservico.SubCodigoEntity</class>
        <class>br.com.netsoft.model.notafiscalservico.TipoCancelamentoEntity</class>
        <class>br.com.netsoft.model.notafiscalservico.TipoCreditoEntity</class>
        <!-- todos -->
        <class>br.com.netsoft.model.todos.AtualizacaoMonetariaEntity</class>
        <class>br.com.netsoft.model.todos.AtualizacaoMonetariaItemEntity</class>
        <class>br.com.netsoft.model.todos.CnaeEntity</class>
        <class>br.com.netsoft.model.todos.CompetenciaEntity</class>
        <class>br.com.netsoft.model.todos.EnderecoEntity</class>
        <class>br.com.netsoft.model.todos.EntidadeEmailConfiguracaoEntity</class>
        <class>br.com.netsoft.model.todos.EntidadeEnderecoEntity</class>
        <class>br.com.netsoft.model.todos.EntidadeEntity</class>
        <class>br.com.netsoft.model.todos.GuiaEntity</class>
        <class>br.com.netsoft.model.todos.NaturezaOperacaoEntity</class>
        <class>br.com.netsoft.model.todos.PessoaEnderecoEntity</class>
        <class>br.com.netsoft.model.todos.PessoaEntidadeEntity</class>
        <class>br.com.netsoft.model.todos.PessoaEntity</class>
        <class>br.com.netsoft.model.todos.PessoaTipoPessoaEntity</class>
        <class>br.com.netsoft.model.todos.PessoaUsuarioEntity</class>
        <class>br.com.netsoft.model.todos.ReceitaEntity</class>
        <class>br.com.netsoft.model.todos.RegimeTributacaoEntity</class>
        <!-- usuario -->
        <class>br.com.netsoft.model.usuario.GrupoEntity</class>
        <class>br.com.netsoft.model.usuario.SistemaEntity</class>
        <class>br.com.netsoft.model.usuario.UsuarioEntidadeEntity</class>
        <class>br.com.netsoft.model.usuario.UsuarioEntity</class>
        <class>br.com.netsoft.model.usuario.UsuarioEntradaSaidaEntity</class>
        <class>br.com.netsoft.model.usuario.UsuarioGrupoSistemaEntity</class>
        <class>br.com.netsoft.model.usuario.UsuarioLogEntity</class>

    </persistence-unit>
</persistence>

O que pode ser ?

Opa, qual o problema que está acontecendo? De todo jeito, só colocando o xml não vai ser suficiente... Teremos que olhar ele todo e torcer para acharmos um detalhe errado.. Quando você inicia o projeto, qual erro acontece?

solução!

Resolvemos não mudar mais.