小编Dre*_*208的帖子

考虑在配置中定义一个'package'类型的bean [Spring-Boot]

我收到以下错误:

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 0 of method setApplicant in webService.controller.RequestController required a bean of type 'com.service.applicant.Applicant' that could not be found.


Action:

Consider defining a bean of type 'com.service.applicant.Applicant' in your configuration.
Run Code Online (Sandbox Code Playgroud)

我之前从未见过这个错误,但@Autowire无法正常工作,这很奇怪.这是项目结构:

申请人界面

public interface Applicant {

    TApplicant findBySSN(String ssn) throws ServletException;

    void deleteByssn(String ssn) throws ServletException;

    void createApplicant(TApplicant tApplicant) throws ServletException;

    void updateApplicant(TApplicant tApplicant) throws ServletException;

    List<TApplicant> getAllApplicants() throws ServletException;
}
Run Code Online (Sandbox Code Playgroud)

ApplicantImpl

@Service
@Transactional
public class ApplicantImpl implements Applicant {

private static Log …
Run Code Online (Sandbox Code Playgroud)

java spring-boot

78
推荐指数
11
解决办法
24万
查看次数

使用JPA更新查询的DML操作不支持

这已被问过一次,但解决方案没有解决问题.我正在创建一个JUnit测试:

 @Test
    @Transactional
    @Modifying
    public void updateMaterialInventory() throws Exception{

        // Initialize the database
        materialRepository.saveAndFlush(material);

        long id =  material.getId();
        materialRepository.updateMaterialInventory(id,UPDATED_INVENTORY_COUNT);

        assertEquals(material.getInventory_count(), UPDATED_INVENTORY_COUNT, 0);
    }
Run Code Online (Sandbox Code Playgroud)

上面测试的调用是:

 @Query("UPDATE Material m SET m.inventory_count = ?2 WHERE m.id = ?1")
    void updateMaterialInventory(Long id,int newInventoryAmount);
Run Code Online (Sandbox Code Playgroud)

错误:

Caused by: org.hibernate.hql.internal.QueryExecutionRequestException: Not supported for DML operations [UPDATE com.htd.domain.Material m SET m.inventory_count = ?2 WHERE m.id = ?1]
    at org.hibernate.hql.internal.ast.QueryTranslatorImpl.errorIfDML(QueryTranslatorImpl.java:318)
    at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:369)
    at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:231)
    at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1264)
    at org.hibernate.internal.QueryImpl.list(QueryImpl.java:103)
    at org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:573)
    at org.hibernate.jpa.internal.QueryImpl.getSingleResult(QueryImpl.java:495)
    ... 55 more
Run Code Online (Sandbox Code Playgroud)

java hibernate jpa hql spring-mvc

40
推荐指数
1
解决办法
3万
查看次数

参数绑定的名称不能为null或为空!对于命名参数,您需要在Java版本上使用@Param作为查询方法参数

这已经发布过,但我的问题有点不同.这是有问题的JPQL查询:

@Query("SELECT NEW com.htd.domain.ShopOrder(po.id, po.po_number, "
            + "po.due_date, po_part.id, po_part.part_quantity, "
            + "part.id, part.part_number, part.part_description, "
            + "part.plasma_hrs_per_part, part.grind_hrs_per_part, "
            + "part.mill_hrs_per_part, part.brakepress_hrs_per_part) "
            + "FROM Po po "
            + "LEFT JOIN po.partList po_part "
            + "LEFT JOIN po_part.part part "
            + "LEFT JOIN po_part.part where po.id = :id")
    List<ShopOrder> getShopOrder(long id);
Run Code Online (Sandbox Code Playgroud)

现在我确实尝试过:

@Query("SELECT NEW com.htd.domain.ShopOrder(po.id, po.po_number, "
            + "po.due_date, po_part.id, po_part.part_quantity, "
            + "part.id, part.part_number, part.part_description, "
            + "part.plasma_hrs_per_part, part.grind_hrs_per_part, "
            + "part.mill_hrs_per_part, part.brakepress_hrs_per_part) "
            + "FROM Po po …
Run Code Online (Sandbox Code Playgroud)

java jpa jpql spring-data-jpa

24
推荐指数
2
解决办法
4万
查看次数

无法在'Element'上执行'setAttribute':']'不是有效的属性名称.角4

我收到以下错误:

Failed to execute 'setAttribute' on 'Element': ']' is not a valid attribute name.
Run Code Online (Sandbox Code Playgroud)

我简单地做了模特:

export interface ModalComponentModel {
    username: string;
    password: string;
    password2: string;
    description: string;
}
Run Code Online (Sandbox Code Playgroud)

我在我的组件中使用它:

零件:

model: ModalComponentModel;
Run Code Online (Sandbox Code Playgroud)

然后我尝试在我的html文件中使用它:

    <div class="modal-header">
    <h4 class="modal-title text-center">Edit Profile</h4>
    <button type="button" class="close" aria-label="Close" (click)="activeModal.dismiss('Cross click')">
        <span aria-hidden="true">&times;</span>
    </button>
</div>
<div class="modal-body">
    <div class="row">
        <div class="col-md-2 col-md-offset-2">
            <form class="form" role="form" (ngSubmit)="whatDoesThisFormDo()">
                <div class="form-group">
                    <label for="username">Username</label>
                    <input type="text" class="form-control" name="username" id="username" placeholder="Your username"
                           [(ngModel)]="model.username">
                </div>
                <div class="form-group">
                    <label for="password1">Password</label>
                    <input type="password" class="form-control" …
Run Code Online (Sandbox Code Playgroud)

angular

23
推荐指数
5
解决办法
5万
查看次数

解析模板"index"时出错,模板可能不存在,或者任何已配置的模板解析器都可能无法访问

之前已经问过这个问题,但我没有解决我的问题而且我得到了一些奇怪的功能.

如果我将index.html文件放在静态目录中,如下所示:

在此输入图像描述

我在浏览器中收到以下错误:

在此输入图像描述

在我的控制台中:

[THYMELEAF][http-nio-8080-exec-3] Exception processing template "login": 
Exception parsing document: template="login", line 6 - column 3
2015-08-11 16:09:07.922 ERROR 5756 --- [nio-8080-exec-3] o.a.c.c.C.[.[.[/].
[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] 
in context with path [] threw exception [Request processing failed; nested 
exception is org.thymeleaf.exceptions.TemplateInputException: Exception 
parsing document: template="login", line 6 - column 3] with root cause

org.xml.sax.SAXParseException: The element type "meta" must be terminated by 
the matching end-tag "</meta>".
Run Code Online (Sandbox Code Playgroud)

但是,如果我将index.html文件移动到templates目录中,我的浏览器中会出现以下错误: 在此输入图像描述

在此输入图像描述

我添加了我的视图解析器:

@Controller
@EnableWebMvc
public class WebController extends WebMvcConfigurerAdapter { …
Run Code Online (Sandbox Code Playgroud)

thymeleaf spring-boot

22
推荐指数
7
解决办法
12万
查看次数

如何通过身份验证所需的Spring-boot安全性

我输入了"root"密码,它不断弹出.我怎么能抑制它或摆脱它.我正在使用弹簧靴和弹簧安全.

在此输入图像描述

application.properties

spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/springbootpractice
spring.datasource.username=root


spring.jpa.database = MYSQL
spring.jpa.show-sql = true

# Hibernate
hibernate.dialect: org.hibernate.dialect.MySQL5Dialect
hibernate.show_sql: true
hibernate.hbm2ddl.auto: update
entitymanager.packagesToScan: /
Run Code Online (Sandbox Code Playgroud)

如果重要的话,我正在使用intellij 14.

----更新1 -----

@Configuration
@EnableWebMvcSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
                .authorizeRequests()
                .antMatchers("/", "/index").permitAll()
                .anyRequest().authenticated()
                .and()
                .formLogin()
                .loginPage("/index")
                .permitAll()
                .and()
                .logout()
                .permitAll();
    } 

        @Override
        protected void configure(HttpSecurity http) throws Exception {
            http
                    .authorizeRequests()
                    .antMatchers("/", "/index").permitAll()
                    .anyRequest().authenticated()
                    .and()
                    .formLogin()
                    .loginPage("/index")
                    .permitAll()
                    .and()
                    .logout()
                    .permitAll();
        }

        @Autowired
        public void configureGlobal(AuthenticationManagerBuilder auth) …
Run Code Online (Sandbox Code Playgroud)

intellij-idea spring-security spring-boot

18
推荐指数
3
解决办法
2万
查看次数

Spring引导在webapp文件夹下找不到index.html

我从spring.io中读到了以下文档,By default Spring Boot will serve static content from a directory called /static (or /public or /resources or /META-INF/resources) in the classpath但是当我将index.html文件放在/resources字符串下时,它就会index被渲染.目前index.html正在使用webapp,我正在使用AngularJS.

目录

MvcConfiguration

@Configuration
public class MvcConfig {

    @Bean
    InternalResourceViewResolver viewResolver(){

        InternalResourceViewResolver resolver = new InternalResourceViewResolver();
        resolver.setPrefix("/webapp/");
        resolver.setSuffix(".html");

        return resolver;
    }

}
Run Code Online (Sandbox Code Playgroud)

索引页面的Restful Service

@RestController
public class IndexController {

    @RequestMapping("/")
    public String index(){
        System.out.println("Looking in the index controller.........");
        return "index";
    }

}
Run Code Online (Sandbox Code Playgroud)

在我的IDE控制台上,我确实看到Looking in the index controller......从IndexController和网络中打印出来的Chrome开发工具我只看到了localhost …

java spring spring-mvc angularjs spring-boot

11
推荐指数
1
解决办法
2万
查看次数

\Dockerfile: 系统找不到指定的文件

我创建了一个 docker 文件来使用 node.js 和 nginx。当我运行时docker -t build <my docker file name> .,出现以下错误:

Dockerfile:系统找不到指定的文件。

然后在 docker 文件目录中,我创建了一个文件夹名称web并将我的 index.html 和 style.css 文件放在其中。

问题是:知道为什么我会收到此错误吗?

docker dockerfile

11
推荐指数
1
解决办法
9737
查看次数

序列不存在,hibernate和JPA 2.1

我收到一个错误说

`Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet] with root cause
java.sql.SQLSyntaxErrorException: ORA-02289: sequence does not exist`
Run Code Online (Sandbox Code Playgroud)

当我尝试创建用户时会发生此错误.

  @RequestMapping(method = POST)
    public UserDto createUser(@RequestBody userDto user) {
        Preconditions.checkNotNull(user);

        return Preconditions.checkNotNull(service.create(user));
    }
Run Code Online (Sandbox Code Playgroud)

然而,我能够delete而且get也不createupdate.令人沮丧的是,我在尝试时没有出现任何错误update,它只是不是这样.

我没有真正领先于哪里看.我尝试了许多不同的方法来解决这个问题,但没有用.

我发现了一篇帖子:

@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="SEQUENCE1")
@SequenceGenerator(name="SEQUENCE1", sequenceName="SEQUENCE1", allocationSize=1)
private int user_id;
Run Code Online (Sandbox Code Playgroud)

在此链接:SOF链接 …

jpa spring-data-jpa spring-boot

10
推荐指数
1
解决办法
901
查看次数

没有ComponentLoaderFactory的提供者

我更新了我的angular2项目,之前它工作正常.但是现在我收到以下错误:

Error: Uncaught (in promise): Error: Error in ./RibbonComponent class 
RibbonComponent - inline template:4:5 caused by: No provider for 
ComponentLoaderFactory!
Error: Error in ./RibbonComponent class RibbonComponent - inline 
template:4:5 caused by: No provider for ComponentLoaderFactory!
Run Code Online (Sandbox Code Playgroud)

ComponentLoaderFactory

export declare class ComponentLoaderFactory {
    private _componentFactoryResolver;
    private _ngZone;
    private _injector;
    private _posService;
    constructor(componentFactoryResolver: ComponentFactoryResolver, ngZone: NgZone, injector: Injector, posService: PositioningService);
    /**
     *
     * @param _elementRef
     * @param _viewContainerRef
     * @param _renderer
     * @returns {ComponentLoader}
     */
    createLoader<T>(_elementRef: ElementRef, _viewContainerRef: ViewContainerRef, _renderer: Renderer): ComponentLoader<T>;
} …
Run Code Online (Sandbox Code Playgroud)

angular

9
推荐指数
3
解决办法
7997
查看次数