Last active
May 23, 2024 16:29
-
-
Save deidine/57b04d6864a5d08a57302e22ae102d71 to your computer and use it in GitHub Desktop.
this gist is for problem solved in differ language and framwork
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
/* | |
######spring boot##### | |
you should add dependecy if existe in this path C:\Users\Republic Of Computer\.m2\repository and search for file that | |
have extension .pom | |
______1____ | |
@SpringBootApplication(scanBasePackages={"com.deidine.start.repository.EmployeeRepository"}) | |
or | |
@ComponentScan({"com.deidine.start.repository.EmployeeRepository"}) | |
if error is | |
Action: | |
Consider defining a bean of type 'com.deidine.start.repository.EmployeeRepository' in your configuration. | |
or the eror isWhitelabel Error Page | |
use restcontroller and request maping then scan the repository | |
_______2_____ | |
##error=>Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. Reason: Failed to determine a suitable driver class | |
##solve=>add this to application.proprites | |
spring.datasource.url=jdbc:mysql://localhost:3306/db | |
spring.datasource.username= | |
spring.datasource.password= | |
spring.datasource.driver-class-name=com.mysql.jdbc.Driver | |
spring.jpa.database-platform = org.hibernate.dialect.MySQL5Dialect | |
spring.jpa.generate-ddl=true | |
spring.jpa.hibernate.ddl-auto = update | |
________3_____ to add package you have to put it inside depency in pom.xml | |
mysql version in pom.xml is <version>8.0.24</version> | |
_______4______ | |
java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver | |
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) | |
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) | |
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525) | |
slove add this | |
@SpringBootApplication (exclude = {DataSourceAutoConfiguration.class }) | |
_______5______ | |
the error | |
Action: | |
Consider defining a bean of type 'com.deidine.deidine.service.DepartmentService' in your configuration. | |
don't put the autowired in the controller file because it will cause wihte page error | |
_____6____ | |
@OneToMany(mappedBy = "entite") you should add mappedby to not create other table | |
user=>(1,n)photo @OneToMany(mappedBy = "user") private List<Photo> photos; | |
photo=>(1,1)user @ManyToOne @JoinColumn(name = "user_id") private User user; | |
@JsonIgnore @ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "roles")private Set<User> users = new HashSet<>(); | |
@ManyToMany(fetch = FetchType.EAGER,cascade = CascadeType.ALL) | |
@JoinTable(name = "link_user_role",joinColumns = {@JoinColumn(name = "user_id",referencedColumnName = "id")},inverseJoinColumns = {@JoinColumn(name = "role_id",referencedColumnName = "id")}) | |
private Set<Role> roles = new HashSet<>(); | |
_____7_____ | |
error if you redirect to login page evry time you run the app | |
solved | |
add this to application (exclude = { SecurityAutoConfiguration.class }) | |
______8_____ | |
if you get 403 evry time you send post request use this | |
.csrf().disable(); | |
______9_________ | |
error ==>The bean 'metaDataSourceAdvisor' could not be registered. A bean with that name has already been defined and overriding is disabled. | |
solve if you createin two file in screrty that have this @EnableGlobalMethodSecurity you should use only one in the project | |
______10_________ | |
error=>The bean 'modelMapper', defined in net.javaguides.springboot.SpringbootBackendApplication, could not be registered. A bean with that name has already been defined in class path resource [net/javaguides/springboot/configuration/SwaggerConfig.class] and overriding is disabled. | |
slove ==> | |
@Configuration | |
public class ModelMapperConfig { | |
@Bean | |
public ModelMapper modelMapper() { | |
return new ModelMapper(); | |
} | |
} | |
___11_____ | |
error => Fail-safe cleanup (collections) : org.hibernate.engine.loading.internal.CollectionLoadContext | |
Springboot Hibernate One to Many infinty recursion create recursion jsion in jsion in json | |
solveed => put @JsonIgnore on the top ove the relation onetomany and manytoone in the entity | |
If you want to generate the json with the parent but not with the children, you can annotate users with @JsonBackReference and activities with @JsonManagedReference | |
or add this to the top of the class | |
@JsonIdentityInfo(generator=ObjectIdGenerators.IntSequenceGenerator.class, property="@id") | |
_____________12___________________ | |
public void RemoveByCart(int id) { | |
// هذي المشكلة فوت اعليها نهار كامل كان خاصني الا نعيط لمستخدم في وسط | |
// user dans le mileu du request de base de donner avec hibrnate | |
// الان العلاقة الوثيقة بين ابنية و المستخدم قوية | |
// @OneToOne(fetch = FetchType.LAZY ) | |
// Class cardF | |
// @JoinColumn(name = "userid", referencedColumnName = "id", nullable = false ) | |
// private User user; | |
Optional<Cart> optionalCart = cartRepo.findById(id); | |
if (optionalCart.isPresent()) { | |
Cart cart = optionalCart.get(); | |
User user = cart.getUser(); | |
cartRepo.delete(cart); | |
// Supprimer l'utilisateur séparément si nécessaire | |
// userRepository.delete(user); | |
} | |
} | |
*/ | |
/* | |
#####angular###### | |
______1______ | |
#error=>10% building 3/4 modules 1 active ...t\index.js?http://0.0.0.0:0/sockjs | |
if you can't run the javascrpit project use this in the package.json | |
"start": " SET NODE_OPTIONS=--openssl-legacy-provider && ng serve ", | |
_____2______ | |
@import "~bootstrap/dist/css/bootstrap.css"; | |
--you have to add bootarap to style.css to work in your ptoject | |
--you should import the FormsModule to use ngModel in the form html | |
--you should put path like this 'login' and dont be like this '/login' | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment