首页 \ 问答 \ Spring boot,SOAP,Spring jpa(Spring boot,SOAP,Spring jpa)

Spring boot,SOAP,Spring jpa(Spring boot,SOAP,Spring jpa)

我在Spring启动时遇到了一些问题(SOAP - Apache cxf,Spring jpa)。 当我运行我的项目时,我得到以下错误,但是如果我在1.4.0上更改了Spring启动版本,那么它确定(但EntityManager为空):我错在哪里?我想用我的SOAP Web服务连接spring-jpa春季启动。

java.lang.IllegalStateException: Could not evaluate condition on org.springframework.boot.devtools.autoconfigure.DevToolsDataSourceAutoConfiguration due to org/springframework/boot/context/embedded/ServletRegistrationBean not found. Make sure your own configuration does not rely on that class. This can also happen if you are @ComponentScanning a springframework package (e.g. if you put a @ComponentScan in the default package by mistake)
at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:55) ~[spring-boot-autoconfigure-1.5.2.RELEASE.jar:1.5.2.RELEASE]
at 

我的application.properties

# server HTTP port
server.port=9090
# set the CXFServlet URL pattern
cxf.path=/codenotfound/ws
# hello world service address
helloworld.service.address=http://localhost:9090/codenotfound/ws/helloworld
spring.datasource.url=jdbc:mysql://localhost:3306/concretepage
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.tomcat.max-wait=20000
spring.datasource.tomcat.max-active=50
spring.datasource.tomcat.max-idle=20
spring.datasource.tomcat.min-idle=15
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQLDialect
spring.jpa.properties.hibernate.id.new_generator_mappings = false
spring.jpa.properties.hibernate.format_sql = true
logging.level.org.hibernate.SQL=DEBUG
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE

我使用DAO方法

@Transactional
@Repository
public class ArticleDAO implements IArticleDAO {
    @PersistenceContext 
    private EntityManager entityManager;    
    @Override
    public Article getArticleById(int articleId) {
        return entityManager.find(Article.class, articleId);
    }
    @SuppressWarnings("unchecked")
    @Override
    public List<Article> getAllArticles() {
        String hql = "FROM Article as atcl ORDER BY atcl.articleId";
        return (List<Article>) entityManager.createQuery(hql).getResultList();
    }   
    @Override
    public void addArticle(Article article) {
        entityManager.persist(article);
    }
    @Override
    public void updateArticle(Article article) {
        Article artcl = getArticleById(article.getArticleId());
        artcl.setTitle(article.getTitle());
        artcl.setCategory(article.getCategory());
        entityManager.flush();
    }
    @Override
    public void deleteArticle(int articleId) {
        entityManager.remove(getArticleById(articleId));
    }
    @Override
    public boolean articleExists(String title, String location) {
        String hql = "FROM Article as atcl WHERE atcl.title = ? and atcl.category = ?";
        int count = entityManager.createQuery(hql).setParameter(1, title)
                      .setParameter(2, location).getResultList().size();
        return count > 0 ? true : false;
    }
}

的pom.xml

  <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.codenotfound</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>demo</name>
    <description>Demo project for Spring Boot</description>
    <url>http://</url>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.2.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <cxf.version>3.1.7</cxf.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional>
        </dependency>
        <!-- Apache CXF-JAXWS-->
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-spring-boot-starter-jaxws</artifactId>
            <version>${cxf.version}</version>
        </dependency>
        <!-- Spring boot Test-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-codegen-plugin</artifactId>
                <version>${cxf.version}</version>
                <executions>
                    <execution>
                        <id>generate-sources</id>
                        <phase>generate-sources</phase>
                        <configuration>
                            <sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
                            <wsdlOptions>
                                <wsdlOption>
                                    <wsdl>${project.basedir}/src/main/resources/wsdl/helloworld.wsdl</wsdl>
                                    <wsdlLocation>classpath:wsdl/helloworld.wsdl</wsdlLocation>
                                </wsdlOption>
                            </wsdlOptions>
                        </configuration>
                        <goals>
                            <goal>wsdl2java</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

我试图在这里调用这个方法

public class HelloWorldImpl implements HelloWorldPortType {
    @Autowired
    private IArticleDAO articleDAO;
    private static final Logger LOGGER = LoggerFactory
            .getLogger(HelloWorldImpl.class);

    @Override
    public Greeting sayHello(Person request) {
        LOGGER.info(
                "Endpoint received person=[firstName:{},lastName:{}]",
                request.getFirstName(), request.getLastName());
        List<Article> _list = articleDAO.getAllArticles();
        System.out.println("title: " + _list.get(0));
        String greeting = "Hello " + "rasras" + " "
                + request.getLastName() + "!";
        ObjectFactory factory = new ObjectFactory();
        Greeting response = factory.createGreeting();
        response.setGreeting(greeting);

        LOGGER.info("Endpoint sending greeting=[{}]",
                response.getGreeting());
        return response;
    }
}

主类

@SpringBootApplication
public class SpringCxfApplication {
    public static void main(String[] args) {
        SpringApplication.run(SpringCxfApplication.class, args);
    }
}

项目结构


i have few problems with Spring boot(SOAP - Apache cxf,Spring jpa). When i run my project, i get following error, but if i change Spring boot version on 1.4.0, its ok(but EntityManager is null): Where was I wrong?I want to connect spring-jpa with my SOAP web service using Spring boot.

java.lang.IllegalStateException: Could not evaluate condition on org.springframework.boot.devtools.autoconfigure.DevToolsDataSourceAutoConfiguration due to org/springframework/boot/context/embedded/ServletRegistrationBean not found. Make sure your own configuration does not rely on that class. This can also happen if you are @ComponentScanning a springframework package (e.g. if you put a @ComponentScan in the default package by mistake)
at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:55) ~[spring-boot-autoconfigure-1.5.2.RELEASE.jar:1.5.2.RELEASE]
at 

my application.properties

# server HTTP port
server.port=9090
# set the CXFServlet URL pattern
cxf.path=/codenotfound/ws
# hello world service address
helloworld.service.address=http://localhost:9090/codenotfound/ws/helloworld
spring.datasource.url=jdbc:mysql://localhost:3306/concretepage
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.tomcat.max-wait=20000
spring.datasource.tomcat.max-active=50
spring.datasource.tomcat.max-idle=20
spring.datasource.tomcat.min-idle=15
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQLDialect
spring.jpa.properties.hibernate.id.new_generator_mappings = false
spring.jpa.properties.hibernate.format_sql = true
logging.level.org.hibernate.SQL=DEBUG
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE

I using DAO method

@Transactional
@Repository
public class ArticleDAO implements IArticleDAO {
    @PersistenceContext 
    private EntityManager entityManager;    
    @Override
    public Article getArticleById(int articleId) {
        return entityManager.find(Article.class, articleId);
    }
    @SuppressWarnings("unchecked")
    @Override
    public List<Article> getAllArticles() {
        String hql = "FROM Article as atcl ORDER BY atcl.articleId";
        return (List<Article>) entityManager.createQuery(hql).getResultList();
    }   
    @Override
    public void addArticle(Article article) {
        entityManager.persist(article);
    }
    @Override
    public void updateArticle(Article article) {
        Article artcl = getArticleById(article.getArticleId());
        artcl.setTitle(article.getTitle());
        artcl.setCategory(article.getCategory());
        entityManager.flush();
    }
    @Override
    public void deleteArticle(int articleId) {
        entityManager.remove(getArticleById(articleId));
    }
    @Override
    public boolean articleExists(String title, String location) {
        String hql = "FROM Article as atcl WHERE atcl.title = ? and atcl.category = ?";
        int count = entityManager.createQuery(hql).setParameter(1, title)
                      .setParameter(2, location).getResultList().size();
        return count > 0 ? true : false;
    }
}

pom.xml

  <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.codenotfound</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>demo</name>
    <description>Demo project for Spring Boot</description>
    <url>http://</url>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.2.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <cxf.version>3.1.7</cxf.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional>
        </dependency>
        <!-- Apache CXF-JAXWS-->
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-spring-boot-starter-jaxws</artifactId>
            <version>${cxf.version}</version>
        </dependency>
        <!-- Spring boot Test-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-codegen-plugin</artifactId>
                <version>${cxf.version}</version>
                <executions>
                    <execution>
                        <id>generate-sources</id>
                        <phase>generate-sources</phase>
                        <configuration>
                            <sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
                            <wsdlOptions>
                                <wsdlOption>
                                    <wsdl>${project.basedir}/src/main/resources/wsdl/helloworld.wsdl</wsdl>
                                    <wsdlLocation>classpath:wsdl/helloworld.wsdl</wsdlLocation>
                                </wsdlOption>
                            </wsdlOptions>
                        </configuration>
                        <goals>
                            <goal>wsdl2java</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

And I'm trying to call this method here

public class HelloWorldImpl implements HelloWorldPortType {
    @Autowired
    private IArticleDAO articleDAO;
    private static final Logger LOGGER = LoggerFactory
            .getLogger(HelloWorldImpl.class);

    @Override
    public Greeting sayHello(Person request) {
        LOGGER.info(
                "Endpoint received person=[firstName:{},lastName:{}]",
                request.getFirstName(), request.getLastName());
        List<Article> _list = articleDAO.getAllArticles();
        System.out.println("title: " + _list.get(0));
        String greeting = "Hello " + "rasras" + " "
                + request.getLastName() + "!";
        ObjectFactory factory = new ObjectFactory();
        Greeting response = factory.createGreeting();
        response.setGreeting(greeting);

        LOGGER.info("Endpoint sending greeting=[{}]",
                response.getGreeting());
        return response;
    }
}

main class

@SpringBootApplication
public class SpringCxfApplication {
    public static void main(String[] args) {
        SpringApplication.run(SpringCxfApplication.class, args);
    }
}

Project structure


原文:https://stackoverflow.com/questions/43522598
更新时间:2022-08-27 12:08

最满意答案

更改为下面的代码,并得到了工作..

"ajax": {
           "url": "/ManageRoutes/GetRoutes",
           "type": "POST",
           "data": function (d) {
            d.szLocationID = Location;
         }

Changed as below code and got worked ..

"ajax": {
           "url": "/ManageRoutes/GetRoutes",
           "type": "POST",
           "data": function (d) {
            d.szLocationID = Location;
         }

相关问答

更多
  • 如果您尝试仅为jqGrid解决问题,则可以选择另一种方法。 您可以使用editUrl或searchSelect的 dataUrl和buildSelect属性来代替value属性。 这些功能是专门为AJAX中的使用而介绍的。 dataUrl以类似的形式定义url提供的结果 如果因为你更容易从服务器返回JSON结果,你的自定义函数buildSelect将 ...
  • 您正确使用filterToolbar 。 您没有任何细节,只写了“我的filterToolbar无法正常工作”。 我想你没有在服务器端实现过滤。 如果用户在过滤器工具栏中输入过滤器,则新请求将被发送到服务器(到'/JqGridClients/DynamicGridData/' )。 选项filter具有文档中描述的格式。 查看答案或另一个代码示例。 如果您需要显示的网格中的行数不是那么大(例如,少于1000行),那么您可以通过使用客户端分页和过滤来简化代码。 您只需进行以下更改: 将loadonce: tr ...
  • 我想你放置了语句$.extend($.jgrid.del, { mtype: "DELETE"}); 在错误的地方。 此外,使用$.extend非深度版本是$.extend 。 我建议你使用 $.extend(true, $.jgrid.del, { mtype: "DELETE"}); 代替。 此外,您可以直接在navGrid 的删除选项列表中放置mtype: "DELETE" 。 请始终在所有问题中写下您使用的jqGrid版本和jqGrid的分支( 免费jqGrid , Guriddo jqGrid ...
  • 看看部署asp.net mvc beta到iis 6导致404和http://blog.stevensanderson.com/2008/07/04/options-for-deploying-aspnet-mvc-to-iis-6/ 。 您的应用程序中是否有更多使用POST的URL? 它们有效吗? 你有没有像.aspx或.mvc这样的扩展名的网址吗? 它们有效吗? 更新 :我在像你这样的所有JavaScripts中遇到了我的URL的不同基本/根部分的问题。 因为你使用jqGrid,我认为你有同样的问题。 ...
  • 你应该明白,如果你想用数据填充JQrid ,你应该将特定的Json集合传递给它。 有两种方法可以做到这一点。 第一道路 如果使用默认的JQgrid设置 ,则可以将此集合传递给Json() Controller方法: public class Row { public string id { get; set; } public List cell { get; set; } public Row() { ...
  • 更改为下面的代码,并得到了工作.. "ajax": { "url": "/ManageRoutes/GetRoutes", "type": "POST", "data": function (d) { d.szLocationID = Location; } Changed as below code and got worked .. "ajax": { "url": "/M ...
  • 我建议你使用multiselect: true而不是列name: 'check' 。 另外,您可以从控制器操作GetDataForCompanyJqGrid以非常简单的形式返回数据,例如,以下内容: [ {"CompanyID": 123, "CompanyName": "Company name 1"}, {"CompanyID": 345, "CompanyName": "Company name 2"}, ... {"CompanyID": 456, "CompanyN ...
  • 你试过看搜索维基吗? 看起来您的列定义应该如下所示: colModel: [ ... {name:'price', index:'price', width:60, search:true, stype:'text', searchoptions:{dataInit:datePick, attr:{title:'Select Date'}} }, ... ] have you tried looking at the search wiki? it looks ...
  • jaGrid将rowid作为id发送,但是你使用了 $deptid = $_POST['idms_department']; 然后在更新中WHERE idms_department = '$deptid'" 。您必须将上述语句更改为 $deptid = $_POST['id']; 或者使用prmNames: {id: "idms_department"}选项来重命名将在编辑期间发送到"idms_department" "id"变量。 jaGrid send rowid as id, but you us ...
  • 我认为问题的存在是因为你在事件处理程序中创建了网格( $('#jsTree_DonVi').on('changed.jstree', function (e, data) {/* here */});这很重要要理解jqGrid在相对复杂的表和div结构中转换初始的空
    。有关详细信息,请参阅帖子 。 例如,您可以通过使用GridUnload方法来解决问题。 你可以更换线路 $("#jqGrid").setGridParam({ datatype: 'jso ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。